Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1.35 KB

logging.md

File metadata and controls

44 lines (32 loc) · 1.35 KB

Logging best practices we follow

  1. Use lowercase for log messages, except for proper nouns
slog.Info("Starting DiceDB", slog.String("version", config.DiceDBVersion))  // not okay
slog.Info("starting DiceDB", slog.String("version", config.DiceDBVersion))  // okay
  1. Be concise, yet informative
slog.Info("DiceDB is starting, initialization in progress", slog.String("version", config.DiceDBVersion))  // not okay
slog.Info("starting DiceDB", slog.String("version", config.DiceDBVersion))  // okay
  1. Use structured logging with key-value pairs
slog.Info("running on port", config.Port)  // not okay
slog.Info("running with", slog.Int("port", config.Port))  // okay
  1. Avoid logging redundant information
slog.Info("running in multi-threaded mode with", slog.String("mode", "multi-threaded"), slog.Int("num-shards", numShards))  // not okay
slog.Info("running with", slog.String("mode", "multi-threaded"), slog.Int("num-shards", numShards))  // okay
  1. Use Boolean values effectively
slog.Info("enable-watch is set to true", slog.Bool("enable-watch", true))  // not okay
slog.Info("running with", slog.Bool("enable-watch", config.EnableWatch))  // okay
  1. Log specific details over general statements
slog.Info("server is running")  // not okay
slog.Info("running with", slog.Int("port", config.Port))  // okay