Skip to content

Latest commit

 

History

History
69 lines (56 loc) · 1.49 KB

logging.md

File metadata and controls

69 lines (56 loc) · 1.49 KB

Logging Best Practices

Be concise, yet informative

Bad practice:

slog.Info("DiceDB is starting, initialization in progress", slog.String("version", config.DiceDBVersion))

Good practice:

slog.Info("starting DiceDB", slog.String("version", config.DiceDBVersion))

Use structured logging with key-value pairs

Bad practice:

slog.Info("running on port", config.Port)

Good practice:

slog.Info("running with", slog.Int("port", config.Port))

Avoid logging redundant information

Bad practice:

slog.Info("running in multi-threaded mode with", slog.String("mode", "multi-threaded"), slog.Int("num-shards", numShards))

Good practice:

slog.Info("running with", slog.String("mode", "multi-threaded"), slog.Int("num-shards", numShards))

Use Boolean values effectively

Bad practice:

slog.Info("enable-watch is set to true", slog.Bool("enable-watch", true))

Good practice:

slog.Info("running with", slog.Bool("enable-watch", config.EnableWatch))

Log specific details over general statements

Bad practice:

slog.Info("server is running")

Good practice:

slog.Info("running with", slog.Int("port", config.Port), slog.Bool("enable-watch", config.EnableWatch))

Use lowercase for log messages, except for proper nouns

Bad practice:

slog.Info("Starting DiceDB", slog.String("version", config.DiceDBVersion))

Good practice:

slog.Info("starting DiceDB", slog.String("version", config.DiceDBVersion))