Skip to content

Commit

Permalink
Add section about log/error messages to HACKING.md (#276)
Browse files Browse the repository at this point in the history
* Add section about log/error messages to HACKING.md
- add "Code style" to contents

* Update HACKING.md

Co-authored-by: Ben Hoyt <[email protected]>

---------

Co-authored-by: Ben Hoyt <[email protected]>
  • Loading branch information
barrettj12 and benhoyt authored Aug 15, 2023
1 parent 423dba7 commit 836feae
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** (that is, those passed to `logger.Noticef` or `logger.Debugf`) 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 836feae

Please sign in to comment.