Skip to content

Commit

Permalink
Add section about log/error messages to HACKING.md
Browse files Browse the repository at this point in the history
- add "Code style" to contents
  • Loading branch information
barrettj12 committed Aug 15, 2023
1 parent 423dba7 commit 71df835
Showing 1 changed file with 15 additions and 0 deletions.
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":
```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

0 comments on commit 71df835

Please sign in to comment.