global.go 670 B

12345678910111213141516171819202122232425262728293031323334
  1. package hclog
  2. import (
  3. "sync"
  4. )
  5. var (
  6. protect sync.Once
  7. def Logger
  8. // The options used to create the Default logger. These are
  9. // read only when the Default logger is created, so set them
  10. // as soon as the process starts.
  11. DefaultOptions = &LoggerOptions{
  12. Level: DefaultLevel,
  13. Output: DefaultOutput,
  14. }
  15. )
  16. // Return a logger that is held globally. 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. // A short alias for Default()
  26. func L() Logger {
  27. return Default()
  28. }