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

Add section about log/error messages to HACKING.md #276

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [Running the daemon](#running-the-daemon)
- [Using the CLI client](#using-the-cli-client)
- [Using Curl to hit the API](#using-curl-to-hit-the-api)
- [Code style](#code-style)
- [Running the tests](#running-the-tests)
- [Creating a release](#creating-a-release)

Expand Down Expand Up @@ -85,6 +86,8 @@ $ curl --unix-socket ~/pebble/.pebble.socket 'http://localhost/v1/services?names

## Code style

### Imports

Pebble imports should be arranged in three groups:
- standard library imports
- third-party / non-Pebble imports
Expand Down Expand Up @@ -115,6 +118,18 @@ import (
)
```

### Log and error messages

**Log messages** (i.e. those passed to `logger.Noticef`) should begin with a capital letter, and use "Cannot X" rather than "Error Xing":
barrettj12 marked this conversation as resolved.
Show resolved Hide resolved
```go
logger.Noticef("Cannot marshal logs to JSON: %v", err)
```

**Error messages** should be lowercase, and again use "cannot ..." instead of "error ...":
```go
fmt.Errorf("cannot create log client: %w", err)
```


## Running the tests

Expand Down
Loading