this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

also respond to GOLOG_{LOG_LEVEL,LOG_FMT,FILE}

authored by

Brian Olson and committed by
Brian Olson
dd43c550 39f5b5f8

+18 -6
+18 -6
util/cliutil/util.go
··· 256 256 KeepOld int 257 257 } 258 258 259 + func firstenv(env_var_names ...string) string { 260 + for _, env_var_name := range env_var_names { 261 + val := os.Getenv(env_var_name) 262 + if val != "" { 263 + return val 264 + } 265 + } 266 + return "" 267 + } 268 + 259 269 // SetupSlog integrates passed in options and env vars. 260 270 // 261 271 // passing default cliutil.LogOptions{} is ok. ··· 270 280 // 271 281 // BSKYLOG_ROTATE_KEEP=int keep N olg logs (not including current) 272 282 // 273 - // (env vars derived from ipfs logging library) 283 + // The env vars were derived from ipfs logging library, and also respond to some GOLOG_ vars from that library, 284 + // but BSKYLOG_ variables are preferred because imported code still using the ipfs log library may misbehave 285 + // if some GOLOG values are set, especially GOLOG_FILE. 274 286 func SetupSlog(options LogOptions) (*slog.Logger, error) { 275 287 fmt.Fprintf(os.Stderr, "SetupSlog\n") 276 288 var hopts slog.HandlerOptions 277 289 hopts.Level = slog.LevelInfo 278 290 hopts.AddSource = true 279 291 if options.LogLevel == "" { 280 - options.LogLevel = os.Getenv("BSKYLOG_LOG_LEVEL") 292 + options.LogLevel = firstenv("BSKYLOG_LOG_LEVEL", "GOLOG_LOG_LEVEL") 281 293 } 282 294 if options.LogLevel == "" { 283 295 hopts.Level = slog.LevelInfo ··· 298 310 } 299 311 } 300 312 if options.LogFormat == "" { 301 - options.LogFormat = os.Getenv("BSKYLOG_LOG_FMT") 313 + options.LogFormat = firstenv("BSKYLOG_LOG_FMT", "GOLOG_LOG_FMT") 302 314 } 303 315 if options.LogFormat == "" { 304 316 options.LogFormat = "text" ··· 313 325 } 314 326 315 327 if options.LogPath == "" { 316 - options.LogPath = os.Getenv("BSKYLOG_FILE") 328 + options.LogPath = firstenv("BSKYLOG_FILE", "GOLOG_FILE") 317 329 } 318 330 if options.LogRotateBytes == 0 { 319 - rotateBytesStr := os.Getenv("BSKYLOG_ROTATE_BYTES") 331 + rotateBytesStr := os.Getenv("BSKYLOG_ROTATE_BYTES") // no GOLOG equivalent 320 332 if rotateBytesStr != "" { 321 333 rotateBytes, err := strconv.ParseInt(rotateBytesStr, 10, 64) 322 334 if err != nil { ··· 327 339 } 328 340 if options.KeepOld == 0 { 329 341 keepOldUnset := true 330 - keepOldStr := os.Getenv("BSKYLOG_ROTATE_KEEP") 342 + keepOldStr := os.Getenv("BSKYLOG_ROTATE_KEEP") // no GOLOG equivalent 331 343 if keepOldStr != "" { 332 344 keepOld, err := strconv.ParseInt(keepOldStr, 10, 64) 333 345 if err != nil {