Skip to content

Commit

Permalink
refactor: switch to zap logger
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Dec 10, 2018
1 parent 7782a17 commit f7e3b0d
Show file tree
Hide file tree
Showing 35 changed files with 455 additions and 363 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Move old webapp to contrib
* Cleanup old files
* Bump deps
* Switch to go.uber.org/zap for logging

[Full commits list](https://github.com/moul/assh/compare/v2.8.0...master)

Expand Down
33 changes: 33 additions & 0 deletions contrib/generate-loggers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh -e

for pkg in $(git grep func\ | grep .go: | cut -d: -f1 | uniq | xargs -n1 dirname | uniq); do
echo "+ generate $pkg/logger.gen.go"
logname="assh."$(echo $pkg | tr / .)
pkgname=$(basename $pkg)

if [ "$pkg" = "api/node/graphql/models" ]; then
logname="vendor.graphql.models"
fi

if grep "package main" $pkg/*.go >/dev/null 2>/dev/null; then
pkgname="main"
fi

logname="$(echo $logname | sed 's/\.\././g;s/\.$//')"

cat > $pkg/logger.gen.go <<EOF
// Code generated by moul.io/assh/contrib/generate-loggers.sh
package $pkgname
import "go.uber.org/zap"
func logger() *zap.Logger {
return zap.L().Named("$logname")
}
EOF
done

set -x
goimports -w .
9 changes: 9 additions & 0 deletions contrib/webapp/logger.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 22 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
module moul.io/assh

require (
github.com/Masterminds/semver v1.4.2
github.com/Masterminds/semver v1.4.2 // indirect
github.com/Masterminds/sprig v2.16.0+incompatible
github.com/StackExchange/wmi v0.0.0-20180725035823-b12b22c5341f
github.com/aokoli/goutils v1.0.1
github.com/aokoli/goutils v1.0.1 // indirect
github.com/awalterschulze/gographviz v0.0.0-20181013152038-b2885df04310
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb
github.com/docker/docker v0.0.0-20170919203346-7cbbbb95097f
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb // indirect
github.com/docker/docker v0.0.0-20170919203346-7cbbbb95097f // indirect
github.com/docker/go-units v0.3.3
github.com/docker/libcompose v0.0.0-20170915135206-b2c0c6e70069
github.com/dustin/go-humanize v1.0.0
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect
github.com/gin-gonic/gin v1.3.0
github.com/go-ole/go-ole v1.2.1
github.com/golang/protobuf v1.2.0
github.com/golang/protobuf v1.2.0 // indirect
github.com/google/uuid v1.1.0 // indirect
github.com/guelfey/go.dbus v0.0.0-20131113121618-f6a3a2366cc3
github.com/guelfey/go.dbus v0.0.0-20131113121618-f6a3a2366cc3 // indirect
github.com/haklop/gnotifier v0.0.0-20140909091139-0de36badf601
github.com/huandu/xstrings v1.2.0
github.com/huandu/xstrings v1.2.0 // indirect
github.com/imdario/mergo v0.3.6
github.com/json-iterator/go v1.1.5
github.com/json-iterator/go v1.1.5 // indirect
github.com/jtolds/gls v4.2.1+incompatible // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/mattn/go-zglob v0.0.0-20180803001819-2ea3427bfa53
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/moul/flexyaml v0.0.0-20171225152558-f458bfa8afe2
github.com/satori/go.uuid v1.2.0
github.com/pkg/errors v0.8.0
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shirou/gopsutil v2.18.11+incompatible
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4
github.com/sirupsen/logrus v1.2.0
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c
github.com/ugorji/go v1.1.1
github.com/stretchr/testify v1.2.2 // indirect
github.com/ugorji/go v1.1.1 // indirect
github.com/urfave/cli v1.20.0
go.uber.org/atomic v1.3.2 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.9.1
golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 // indirect
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/go-playground/validator.v8 v8.18.2
gopkg.in/yaml.v2 v2.2.2
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
Loading

0 comments on commit f7e3b0d

Please sign in to comment.