global.go 683 B

12345678910111213141516171819202122232425262728293031323334
  1. package hclog
  2. import (
  3. "sync"
  4. )
  5. var (
  6. protect sync.Once
  7. def Logger
  8. // DefaultOptions is used to create the Default logger. These are read
  9. // only when the Default logger is created, so set them as soon as the
  10. // process starts.
  11. DefaultOptions = &LoggerOptions{
  12. Level: DefaultLevel,
  13. Output: DefaultOutput,
  14. }
  15. )
  16. // Default returns a globally held logger. This can be a good starting
  17. // place, and then you can use .With() and .Name() to create sub-loggers
  18. // to be used in more specific contexts.
  19. func Default() Logger {
  20. protect.Do(func() {
  21. def = New(DefaultOptions)
  22. })
  23. return def
  24. }
  25. // L is a short alias for Default().
  26. func L() Logger {
  27. return Default()
  28. }