Yet another Go logging library for user-friendly applications, with colors!

themes.go 1.3KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package log
  2. import "git.kirsle.net/go/log/ansi"
  3. // Theme defines the color scheme for a logger. Each log level has two colors:
  4. // a primary (for the label itself) and a secondary color. For example, if your
  5. // log lines include a date/time this could be colored using the secondary
  6. // color.
  7. type Theme struct {
  8. Debug ThemeColor
  9. DebugSecondary ThemeColor
  10. Info ThemeColor
  11. InfoSecondary ThemeColor
  12. Warn ThemeColor
  13. WarnSecondary ThemeColor
  14. Error ThemeColor
  15. ErrorSecondary ThemeColor
  16. }
  17. // ThemeColor defines a color tuple for ANSI (legacy) support and modern
  18. // 256-color support.
  19. type ThemeColor struct {
  20. ANSI string
  21. Extended string
  22. }
  23. // DarkTheme is a suitable default theme for dark terminal backgrounds.
  24. var DarkTheme = Theme{
  25. Debug: ThemeColor{ansi.BrightCyan, HexColor("#FF99FF")},
  26. DebugSecondary: ThemeColor{ansi.Cyan, HexColor("#996699")},
  27. Info: ThemeColor{ansi.BrightGreen, HexColor("#0099FF")},
  28. InfoSecondary: ThemeColor{ansi.Green, HexColor("#006699")},
  29. Warn: ThemeColor{ansi.BrightYellow, HexColor("#FF9900")},
  30. WarnSecondary: ThemeColor{ansi.Yellow, HexColor("#996600")},
  31. Error: ThemeColor{ansi.BrightRed, HexColor("#FF0000")},
  32. ErrorSecondary: ThemeColor{ansi.Red, HexColor("#CC0000")},
  33. }