diff --git a/CONTRIBUTING.md b/CONTRIBUTING/README.md similarity index 99% rename from CONTRIBUTING.md rename to CONTRIBUTING/README.md index 426a8eac2..ff7994879 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING/README.md @@ -30,6 +30,8 @@ Make the necessary changes. If the changes you plan to make are too big, make su Follow the best practices when you are making changes. +- [Logging Best Practices](logging.md) + ### Code documentation Please ensure your code is adequately documented. Some things to consider for documentation: diff --git a/CONTRIBUTING/logging.md b/CONTRIBUTING/logging.md new file mode 100644 index 000000000..3ec850d24 --- /dev/null +++ b/CONTRIBUTING/logging.md @@ -0,0 +1,26 @@ +Logging Best Practices +=== + +1. Be concise, yet informative + - Bad example: `slog.Info("DiceDB is starting, initialization in progress", slog.String("version", config.DiceDBVersion))` + - Good example: `slog.Info("starting DiceDB", slog.String("version", config.DiceDBVersion))` + +2. Use structured logging with key-value pairs + - Bad example: `slog.Info("running on port", config.Port)` + - Good example: `slog.Info("running with", slog.Int("port", config.Port))` + +3. Avoid logging redundant information + - Bad example: `slog.Info("running in multi-threaded mode with", slog.String("mode", "multi-threaded"), slog.Int("num-shards", numShards))` + - Good example: `slog.Info("running with", slog.String("mode", "multi-threaded"), slog.Int("num-shards", numShards))` + +4. Use Boolean values effectively + - Bad example: `slog.Info("enable-watch is set to true", slog.Bool("enable-watch", true))` + - Good example: `slog.Info("running with", slog.Bool("enable-watch", config.EnableWatch))` + +5. Log specific details over general statements + - Bad example: `slog.Info("server is running")` + - Good example: `slog.Info("running with", slog.Int("port", config.Port), slog.Bool("enable-watch", config.EnableWatch))` + +6. Use lowercase for log messages, except for proper nouns + - Bad example: `slog.Info("Starting DiceDB", slog.String("version", config.DiceDBVersion))` + - Good example: `slog.Info("starting DiceDB", slog.String("version", config.DiceDBVersion))` diff --git a/Makefile b/Makefile index e27ed63c7..121ecb865 100644 --- a/Makefile +++ b/Makefile @@ -59,10 +59,11 @@ unittest-one: go test -v -race -count=1 --run $(TEST_FUNC) ./internal/... release: - git tag v$(VERSION) + git tag $(VERSION) git push origin --tags docker build --tag dicedb/dicedb:latest --tag dicedb/dicedb:$(VERSION) . docker push dicedb/dicedb:$(VERSION) + docker push dicedb/dicedb:latest GOLANGCI_LINT_VERSION := 1.60.1 diff --git a/README.md b/README.md index 6dce91dde..0085c7e23 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,7 @@ DiceDB started as a re-implementation of Redis in Golang and the idea was to - b ## How to contribute -The Code Contribution Guidelines are published at [CONTRIBUTING.md](CONTRIBUTING.md); please read them before you start making any changes. This would allow us to have a consistent standard of coding practices and developer experience. +The Code Contribution Guidelines are published at [CONTRIBUTING/README.md](CONTRIBUTING/README.md); please read them before you start making any changes. This would allow us to have a consistent standard of coding practices and developer experience. Contributors can join the [Discord Server](https://discord.gg/6r8uXWtXh7) for quick collaboration.