Skip to content

Commit 6812bbd

Browse files
authored
chore: fix ci (#145)
1 parent 54768ad commit 6812bbd

File tree

2 files changed

+50
-43
lines changed

2 files changed

+50
-43
lines changed

README.md

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ go get cdr.dev/slog
2020
- First class [testing.TB](https://godoc.org/cdr.dev/slog/sloggers/slogtest) support
2121
- Package [slogtest/assert](https://godoc.org/cdr.dev/slog/sloggers/slogtest/assert) provides test assertion helpers
2222
- Beautiful human readable logging output
23-
- Prints multiline fields and errors nicely
23+
- Prints multiline fields and errors nicely
2424
- Machine readable JSON output
2525
- [GCP Stackdriver](https://godoc.org/cdr.dev/slog/sloggers/slogstackdriver) support
2626
- [Stdlib](https://godoc.org/cdr.dev/slog#Stdlib) log adapter
@@ -59,59 +59,66 @@ log.Info(context.Background(), "my message here",
5959
At [Coder](https://github.com/cdr) we’ve used Uber’s [zap](https://github.com/uber-go/zap) for several years.
6060
It is a fantastic library for performance. Thanks Uber!
6161

62-
However we felt the API and developer experience could be improved.
62+
However we felt the API and developer experience could be improved.
6363

6464
Here is a list of reasons how we improved on zap with slog.
6565

6666
1. `slog` has a minimal API surface
67-
- Compare [slog](https://godoc.org/cdr.dev/slog) to [zap](https://godoc.org/go.uber.org/zap) and
68-
[zapcore](https://godoc.org/go.uber.org/zap/zapcore).
69-
- The sprawling API makes zap hard to understand, use and extend.
67+
68+
- Compare [slog](https://godoc.org/cdr.dev/slog) to [zap](https://godoc.org/go.uber.org/zap) and
69+
[zapcore](https://godoc.org/go.uber.org/zap/zapcore).
70+
- The sprawling API makes zap hard to understand, use and extend.
7071

7172
1. `slog` has a concise semi typed API
72-
- We found zap's fully typed API cumbersome. It does offer a
73-
[sugared API](https://godoc.org/go.uber.org/zap#hdr-Choosing_a_Logger)
74-
but it's too easy to pass an invalid fields list since there is no static type checking.
75-
Furthermore, it's harder to read as there is no syntax grouping for each key value pair.
76-
- We wanted an API that only accepted the equivalent of [zap.Any](https://godoc.org/go.uber.org/zap#Any)
77-
for every field. This is [slog.F](https://godoc.org/cdr.dev/slog#F).
73+
74+
- We found zap's fully typed API cumbersome. It does offer a
75+
[sugared API](https://godoc.org/go.uber.org/zap#hdr-Choosing_a_Logger)
76+
but it's too easy to pass an invalid fields list since there is no static type checking.
77+
Furthermore, it's harder to read as there is no syntax grouping for each key value pair.
78+
- We wanted an API that only accepted the equivalent of [zap.Any](https://godoc.org/go.uber.org/zap#Any)
79+
for every field. This is [slog.F](https://godoc.org/cdr.dev/slog#F).
7880

7981
1. [`sloghuman`](https://godoc.org/cdr.dev/slog/sloggers/sloghuman) uses a very human readable format
80-
- It colors distinct parts of each line to make it easier to scan logs. Even the JSON that represents
81-
the fields in each log is syntax highlighted so that is very easy to scan. See the screenshot above.
82-
- zap lacks appropriate colors for different levels and fields
83-
- slog automatically prints one multiline field after the log to make errors and such much easier to read.
84-
- zap logs multiline fields and errors stack traces as JSON strings which made them unreadable in a terminal.
85-
- When logging to JSON, slog automatically converts a [`golang.org/x/xerrors`](https://golang.org/x/xerrors) chain
86-
into an array with fields for the location and wrapping messages.
82+
83+
- It colors distinct parts of each line to make it easier to scan logs. Even the JSON that represents
84+
the fields in each log is syntax highlighted so that is very easy to scan. See the screenshot above.
85+
- zap lacks appropriate colors for different levels and fields.
86+
- slog automatically prints one multiline field after the log to make errors and such much easier to read.
87+
- zap logs multiline fields and errors stack traces as JSON strings which made them unreadable in a terminal.
88+
- When logging to JSON, slog automatically converts a [`golang.org/x/xerrors`](https://golang.org/x/xerrors) chain
89+
into an array with fields for the location and wrapping messages.
8790

8891
1. Full [context.Context](https://blog.golang.org/context) support
89-
- `slog` lets you set fields in a `context.Context` such that any log with the context prints those fields.
90-
- We wanted to be able to pull up all relevant logs for a given trace, user or request. With zap, we were plugging
91-
these fields in for every relevant log or passing around a logger with the fields set. This became very verbose.
92+
93+
- `slog` lets you set fields in a `context.Context` such that any log with the context prints those fields.
94+
- We wanted to be able to pull up all relevant logs for a given trace, user or request. With zap, we were plugging
95+
these fields in for every relevant log or passing around a logger with the fields set. This became very verbose.
9296

9397
1. Simple and easy to extend
94-
- A new backend only has to implement the simple Sink interface.
95-
- The Logger type provides a nice API around Sink but also implements
96-
Sink to allow for composition.
97-
- zap is hard and confusing to extend. There are too many structures and configuration options.
98+
99+
- A new backend only has to implement the simple Sink interface.
100+
- The Logger type provides a nice API around Sink but also implements
101+
Sink to allow for composition.
102+
- zap is hard and confusing to extend. There are too many structures and configuration options.
98103

99104
1. Structured logging of Go structures with `json.Marshal`
100-
- Entire encoding process is documented on [godoc](https://godoc.org/cdr.dev/slog#Map.MarshalJSON).
101-
- With zap, We found ourselves often implementing zap's
102-
[ObjectMarshaler](https://godoc.org/go.uber.org/zap/zapcore#ObjectMarshaler) to log Go structures. This was
103-
verbose and most of the time we ended up only implementing `fmt.Stringer` and using `zap.Stringer` instead.
105+
106+
- Entire encoding process is documented on [godoc](https://godoc.org/cdr.dev/slog#Map.MarshalJSON).
107+
- With zap, We found ourselves often implementing zap's
108+
[ObjectMarshaler](https://godoc.org/go.uber.org/zap/zapcore#ObjectMarshaler) to log Go structures. This was
109+
verbose and most of the time we ended up only implementing `fmt.Stringer` and using `zap.Stringer` instead.
104110

105111
1. slog takes inspiration from Go's stdlib and implements [`slog.Helper`](https://godoc.org/cdr.dev/slog#Helper)
106112
which works just like [`t.Helper`](https://golang.org/pkg/testing/#T.Helper)
107-
- It marks the calling function as a helper and skips it when reporting location info.
108-
- We had many helper functions for logging but we wanted the line reported to be of the parent function.
109-
zap has an [API](https://godoc.org/go.uber.org/zap#AddCallerSkip) for this but it's verbose and requires
110-
passing the logger around explicitly.
113+
114+
- It marks the calling function as a helper and skips it when reporting location info.
115+
- We had many helper functions for logging but we wanted the line reported to be of the parent function.
116+
zap has an [API](https://godoc.org/go.uber.org/zap#AddCallerSkip) for this but it's verbose and requires
117+
passing the logger around explicitly.
111118

112119
1. Tight integration with stdlib's [`testing`](https://golang.org/pkg/testing) package
113-
- You can configure [`slogtest`](https://godoc.org/cdr.dev/slog/sloggers/slogtest) to exit on any ERROR logs
114-
and it has a global stateless API that takes a `testing.TB` so you do not need to create a logger first.
115-
- Test assertion helpers are provided in [slogtest/assert](https://godoc.org/cdr.dev/slog/sloggers/slogtest/assert).
116-
- zap has [zaptest](https://godoc.org/go.uber.org/zap/zaptest) but the API surface is large and doesn't
117-
integrate well. It does not support any of the features described above.
120+
- You can configure [`slogtest`](https://godoc.org/cdr.dev/slog/sloggers/slogtest) to exit on any ERROR logs
121+
and it has a global stateless API that takes a `testing.TB` so you do not need to create a logger first.
122+
- Test assertion helpers are provided in [slogtest/assert](https://godoc.org/cdr.dev/slog/sloggers/slogtest/assert).
123+
- zap has [zaptest](https://godoc.org/go.uber.org/zap/zaptest) but the API surface is large and doesn't
124+
integrate well. It does not support any of the features described above.

ci/image/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
FROM golang:1
22

3-
RUN apt-get update
4-
RUN apt-get install -y npm
3+
RUN apt-get update && \
4+
apt-get install -y npm
55

66
ENV GOFLAGS="-mod=readonly"
77
ENV PAGER=cat
88
ENV CI=true
99
ENV MAKEFLAGS="--jobs=8 --output-sync=target"
1010

1111
RUN npm install -g prettier
12-
RUN go get golang.org/x/tools/cmd/goimports
13-
RUN go get golang.org/x/lint/golint
14-
RUN go get github.com/mattn/goveralls
12+
RUN go install golang.org/x/tools/cmd/goimports@latest
13+
RUN go install golang.org/x/lint/golint@latest
14+
RUN go install github.com/mattn/goveralls@latest

0 commit comments

Comments
 (0)