github.com/GuanceCloud/cliutils@v1.1.21/logger/env.go (about) 1 // Unless explicitly stated otherwise all files in this repository are licensed 2 // under the MIT License. 3 // This product includes software developed at Guance Cloud (https://www.guance.com/). 4 // Copyright 2021-present Guance, Inc. 5 6 package logger 7 8 import "os" 9 10 func setRootLoggerFromEnv(opt *Option) error { 11 switch opt.Path { 12 case "nul", /* windows */ 13 "/dev/null": /* most UNIX */ 14 return doSetGlobalRootLogger(os.DevNull, opt.Level, opt.Flags) 15 16 case "": 17 return doInitStdoutLogger() 18 19 default: 20 return doSetGlobalRootLogger(opt.Path, opt.Level, opt.Flags) 21 } 22 }