Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contributing Best Practices #1184

Merged
merged 6 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTING.md → CONTRIBUTING/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 26 additions & 0 deletions CONTRIBUTING/logging.md
Original file line number Diff line number Diff line change
@@ -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))`
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down