diff --git a/app/cli.go b/app/cli.go index d276cea10..556ae4f1d 100644 --- a/app/cli.go +++ b/app/cli.go @@ -7,7 +7,6 @@ import ( authCommands "github.com/cortezaproject/corteza-server/auth/commands" federationCommands "github.com/cortezaproject/corteza-server/federation/commands" "github.com/cortezaproject/corteza-server/pkg/cli" - "github.com/cortezaproject/corteza-server/pkg/logger" "github.com/cortezaproject/corteza-server/pkg/options" fakerCommands "github.com/cortezaproject/corteza-server/pkg/seeder/commands" "github.com/cortezaproject/corteza-server/store" @@ -34,8 +33,6 @@ func (app *CortezaApp) InitCLI() { return fmt.Errorf("failed to load environmental variables: %w", err) } - logger.Init() - // Environmental variables (from the env, files, see cli.LoadEnv) MUST be // loaded at this point! app.Opt = options.Init() diff --git a/go.mod b/go.mod index 25ecc8150..d05d2beda 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/cortezaproject/corteza-server go 1.16 require ( - github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 // indirect github.com/766b/chi-prometheus v0.0.0-20180509160047-46ac2b31aa30 github.com/99designs/basicauth-go v0.0.0-20160802081356-2a93ba0f464d github.com/Masterminds/goutils v1.1.0 // indirect @@ -15,8 +14,6 @@ require ( github.com/SentimensRG/ctx v0.0.0-20180729130232-0bfd988c655d github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/brianvoe/gofakeit/v6 v6.5.0 - github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4 // indirect - github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974 // indirect github.com/crewjam/saml v0.4.5 github.com/crusttech/go-oidc v0.0.0-20180918092017-982855dad3e1 github.com/davecgh/go-spew v1.1.1 @@ -55,13 +52,11 @@ require ( github.com/lestrrat-go/strftime v1.0.3 github.com/lib/pq v1.1.0 github.com/markbates/goth v1.67.1 - github.com/mattn/go-shellwords v1.0.12 // indirect github.com/mattn/go-sqlite3 v1.14.0 github.com/microcosm-cc/bluemonday v1.0.10 github.com/minio/minio-go/v6 v6.0.39 github.com/mitchellh/copystructure v1.0.0 // indirect github.com/ngrok/sqlmw v0.0.0-20200129213757-d5c93a81bec6 - github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/pkg/errors v0.9.1 github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect github.com/prometheus/client_golang v0.9.3 @@ -76,7 +71,6 @@ require ( github.com/stretchr/testify v1.7.0 github.com/tebeka/strftime v0.1.5 // indirect go.uber.org/atomic v1.7.0 - go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect go.uber.org/zap v1.19.0 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a // indirect @@ -88,7 +82,7 @@ require ( gopkg.in/ini.v1 v1.51.0 // indirect gopkg.in/mail.v2 v2.3.1 gopkg.in/square/go-jose.v2 v2.3.1 // indirect - gopkg.in/urfave/cli.v1 v1.20.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b + moul.io/zapfilter v1.6.1 rsc.io/qr v0.2.0 ) diff --git a/go.sum b/go.sum index b96710239..00db03a44 100644 --- a/go.sum +++ b/go.sum @@ -33,13 +33,10 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 h1:j9HaafapDbPbGRDku6e/HRs6KBMcKHiWcm1/9Sbxnl4= -github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1/go.mod h1:NtXa9WwQsukMHZpjNakTTz0LArxvGYdPA9CjIcUSZ6s= github.com/766b/chi-prometheus v0.0.0-20180509160047-46ac2b31aa30 h1:bNHbCMKiQxpRNe4Pk2W09N1aXXc4ICOawQFKIDEicqc= github.com/766b/chi-prometheus v0.0.0-20180509160047-46ac2b31aa30/go.mod h1:X/LhbmoBoRu8TxoGIOIraVNhfz3hhikJoaelrOuhdPY= github.com/99designs/basicauth-go v0.0.0-20160802081356-2a93ba0f464d h1:j6oB/WPCigdOkxtuPl1VSIiLpy7Mdsu6phQffbF19Ng= github.com/99designs/basicauth-go v0.0.0-20160802081356-2a93ba0f464d/go.mod h1:3cARGAK9CfW3HoxCy1a0G4TKrdiKke8ftOMEOHyySYs= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= @@ -74,12 +71,11 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/brianvoe/gofakeit v3.18.0+incompatible h1:wDOmHc9DLG4nRjUVVaxA+CEglKOW72Y5+4WNxUIkjM8= -github.com/brianvoe/gofakeit v3.18.0+incompatible/go.mod h1:kfwdRA90vvNhPutZWfH7WPaDzUjz+CZFqG+rPkOjGOc= github.com/brianvoe/gofakeit/v6 v6.5.0 h1:zoWqGsuB8TB4MSwUZXtV3OwUSdzi8EHeXO8JfReRIHg= github.com/brianvoe/gofakeit/v6 v6.5.0/go.mod h1:palrJUk4Fyw38zIFB/uBZqsgzW5VsNllhHKKwAebzew= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -87,16 +83,11 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chris-ramon/douceur v0.2.0/go.mod h1:wDW5xjJdeoMm1mRt4sD4c/LbF/mWdEpRXQKjTR8nIBE= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4 h1:ihrIKrLQzm6Q6NJHBMemvaIGTFxgxQUEkn2AjN0Aulw= -github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4/go.mod h1:X7wHz0C25Lga6CnJ4WAQNbUQ9P/8eWSNv8qIO71YkSM= -github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974 h1:ysuVNDVE4LIky6I+6JlgAKG+wBNKMpVv3m3neVpvFVw= -github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974/go.mod h1:UBYuwaH3dMw91EZ7tGVaFF6GDj5j46S7zqB9lZPIe58= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/crewjam/httperr v0.0.0-20190612203328-a946449404da h1:WXnT88cFG2davqSFqvaFfzkSMC0lqh/8/rKZ+z7tYvI= github.com/crewjam/httperr v0.0.0-20190612203328-a946449404da/go.mod h1:+rmNIXRvYMqLQeR4DHyTvs6y0MEMymTz4vyFpFkKTPs= @@ -161,8 +152,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-oauth2/oauth2/v4 v4.2.0 h1:wz9w9SwHrzC58XniFSGXIfl2R5Q6x1aecVuL/QBupl8= -github.com/go-oauth2/oauth2/v4 v4.2.0/go.mod h1:+rsyi0o/ZbSfhL/3Xr/sAtL4brS+IdGj86PHVlPjE+4= github.com/go-oauth2/oauth2/v4 v4.3.0 h1:vp4goUmrq1YaPzpm34FDLlZiAkIqK3LsuNTTRyTnPbo= github.com/go-oauth2/oauth2/v4 v4.3.0/go.mod h1:+rsyi0o/ZbSfhL/3Xr/sAtL4brS+IdGj86PHVlPjE+4= github.com/go-session/session v3.1.2+incompatible/go.mod h1:8B3iivBQjrz/JtC68Np2T1yBBLxTan3mn/3OM0CyRt0= @@ -282,10 +271,11 @@ github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdY github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= @@ -306,8 +296,6 @@ github.com/mattermost/xml-roundtrip-validator v0.0.0-20201213122252-bcd7e1b9601e github.com/mattermost/xml-roundtrip-validator v0.0.0-20201213122252-bcd7e1b9601e/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk= -github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= @@ -331,8 +319,6 @@ github.com/mrjones/oauth v0.0.0-20180629183705-f4e24b6d100c/go.mod h1:skjdDftzkF github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/ngrok/sqlmw v0.0.0-20200129213757-d5c93a81bec6 h1:evlcQnJY+v8XRRchV3hXzpHDl6GcEZeLXAhlH9Csdww= github.com/ngrok/sqlmw v0.0.0-20200129213757-d5c93a81bec6/go.mod h1:E26fwEtRNigBfFfHDWsklmo0T7Ixbg0XXgck+Hq4O9k= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -400,7 +386,6 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -452,18 +437,15 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= @@ -509,7 +491,6 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -543,7 +524,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 h1:YfxMZzv3PjGonQYNUaeU2+DhAdqOxerQ30JFB6WgAXo= golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -552,7 +532,6 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 h1:ld7aEMNHoBnnDAX15v1T6z31v8HwR2A9FYOuAhWqkwc= golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914 h1:3B43BWw0xEBsLZ/NO1VALz6fppU3481pik+2Ksv45z8= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= @@ -603,8 +582,6 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200918174421-af09f7315aff h1:1CPUrky56AcgSpxz/KfgzQWzfG09u5YOL8MvPYBlrL8= -golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -613,9 +590,7 @@ golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fq golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -762,8 +737,7 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -775,17 +749,14 @@ gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw= gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0= -gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -795,8 +766,9 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +moul.io/zapfilter v1.6.1 h1:D5ySvqGTADgtOmjhKCrCOnH3DHZjIqIAQD0kwCeyBIw= +moul.io/zapfilter v1.6.1/go.mod h1:zfT2z4z2YfI63Kifpe8GMt0M+sBXs8WQ4mfne4bGmic= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= diff --git a/pkg/cli/commands.go b/pkg/cli/commands.go index 4d23fa5d0..5d4e9a309 100644 --- a/pkg/cli/commands.go +++ b/pkg/cli/commands.go @@ -1,11 +1,8 @@ package cli import ( - "github.com/cortezaproject/corteza-server/pkg/logger" "github.com/cortezaproject/corteza-server/pkg/version" "github.com/spf13/cobra" - "go.uber.org/zap" - "os" ) var ( @@ -67,12 +64,6 @@ func RootCommand(ppRunEfn func() error) *cobra.Command { func ServeCommand(runEfn func() error) *cobra.Command { serveApiCommand.RunE = func(cmd *cobra.Command, args []string) (err error) { - if _, set := os.LookupEnv("LOG_LEVEL"); !set { - // If LOG_LEVEL is not explicitly set, let's - // set it to INFO so that it - logger.DefaultLevel.SetLevel(zap.InfoLevel) - } - return runEfn() } diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index ca354bf30..ad6deb74c 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -1,24 +1,58 @@ package logger import ( - "os" "time" + "github.com/cortezaproject/corteza-server/pkg/options" "go.uber.org/zap" "go.uber.org/zap/zapcore" - - "github.com/cortezaproject/corteza-server/pkg/options" + "moul.io/zapfilter" ) var ( - DefaultLevel = zap.NewAtomicLevel() + opt = options.Log() defaultLogger = zap.NewNop() ) +func Default() *zap.Logger { + return defaultLogger +} + +func SetDefault(logger *zap.Logger) { + if logger == nil { + logger = zap.NewNop() + } + + defaultLogger = logger +} + +// Init (re)initializes logger according to the settings +func Init() { + if opt.Debug { + // Do we want to enable debug logger + // with a bit more dev-friendly output + defaultLogger = MakeDebugLogger() + defaultLogger.Debug("full debug mode enabled") + return + } + + var ( + err error + conf = applyOptions(zap.NewProductionConfig(), opt) + ) + + defaultLogger, err = conf.Build() + if err != nil { + panic(err) + } + + defaultLogger = applySpecials(defaultLogger, opt) +} + func MakeDebugLogger() *zap.Logger { - conf := zap.NewDevelopmentConfig() - conf.Level = DefaultLevel - conf.Level.SetLevel(zap.DebugLevel) + var ( + conf = applyOptions(zap.NewDevelopmentConfig(), opt) + ) // Print log level in colors conf.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder @@ -33,71 +67,37 @@ func MakeDebugLogger() *zap.Logger { panic(err) } - logger.Debug("full debug mode enabled (LOG_DEBUG=true)") - - return applyStacktrace(logger, zap.DPanicLevel) + return applySpecials(logger, opt) } -func Init() { - var ( - err error +// Applies options from environment variables +func applyOptions(conf zap.Config, opt *options.LogOpt) zap.Config { + // LOG_LEVEL + conf.Level = zap.NewAtomicLevelAt(mustParseLevel(opt.Level)) - // Set WARN as default log level -- running serve-api - // will override this if LOG_LEVEL is not set - logLevel = zapcore.WarnLevel + // LOG_INCLUDE_CALLER + conf.DisableCaller = !opt.IncludeCaller - // Do we want to enable debug logger - // with a bit more dev-friendly output - debuggingLogger = options.EnvBool("LOG_DEBUG", false) - ) - - if ll, has := os.LookupEnv("LOG_LEVEL"); has { - _ = logLevel.Set(ll) - } - - DefaultLevel.SetLevel(logLevel) - - if debuggingLogger { - defaultLogger = MakeDebugLogger() - return - } - - conf := zap.NewProductionConfig() - conf.Level = DefaultLevel - - // We do not want sampling conf.Sampling = nil - defaultLogger, err = conf.Build() - if err != nil { + return conf +} + +// Applies "special" options - filtering and conditional stack-level +func applySpecials(l *zap.Logger, opt *options.LogOpt) *zap.Logger { + if len(opt.Filter) > 0 { + // LOG_FILTER + l = zap.New(zapfilter.NewFilteringCore(l.Core(), zapfilter.MustParseRules(opt.Filter))) + } + + // LOG_STACKTRACE_LEVEL + return l.WithOptions(zap.AddStacktrace(mustParseLevel(opt.StacktraceLevel))) +} + +func mustParseLevel(l string) (o zapcore.Level) { + if err := o.Set(l); err != nil { panic(err) } - // Add stacktrace ONLY for panics - defaultLogger = applyStacktrace(defaultLogger, zap.PanicLevel) -} - -// applies configured stacktrace level -// -// By default it uses Panic or DPanic (depends if debug logger is used) -// This can be manipulated by setting LOG_STACKTRACE_LEVEL to -// value "debug", "info", "warn", "error", "dpanic", "panic", or "fatal" -func applyStacktrace(in *zap.Logger, def zapcore.Level) *zap.Logger { - if stl, has := os.LookupEnv("LOG_STACKTRACE_LEVEL"); has { - _ = def.UnmarshalText([]byte(stl)) - } - - return in.WithOptions(zap.AddStacktrace(def)) -} - -func Default() *zap.Logger { - return defaultLogger -} - -func SetDefault(logger *zap.Logger) { - if logger == nil { - logger = zap.NewNop() - } - - defaultLogger = logger + return } diff --git a/pkg/options/helpers.go b/pkg/options/helpers.go index 845f1cc0e..6e604d5c6 100644 --- a/pkg/options/helpers.go +++ b/pkg/options/helpers.go @@ -57,7 +57,6 @@ func fill(opt interface{}) { } panic("unsupported type/kind for field " + t.Name) - } } } diff --git a/pkg/options/log.gen.go b/pkg/options/log.gen.go new file mode 100644 index 000000000..fe5a8733f --- /dev/null +++ b/pkg/options/log.gen.go @@ -0,0 +1,41 @@ +package options + +// This file is auto-generated. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// Definitions file that controls how this file is generated: +// pkg/options/log.yaml + +type ( + LogOpt struct { + Debug bool `env:"LOG_DEBUG"` + Level string `env:"LOG_LEVEL"` + Filter string `env:"LOG_FILTER"` + IncludeCaller bool `env:"LOG_INCLUDE_CALLER"` + StacktraceLevel string `env:"LOG_STACKTRACE_LEVEL"` + } +) + +// Log initializes and returns a LogOpt with default values +func Log() (o *LogOpt) { + o = &LogOpt{ + Level: "warn", + IncludeCaller: false, + StacktraceLevel: "dpanic", + } + + fill(o) + + // Function that allows access to custom logic inside the parent function. + // The custom logic in the other file should be like: + // func (o *Log) Defaults() {...} + func(o interface{}) { + if def, ok := o.(interface{ Defaults() }); ok { + def.Defaults() + } + }(o) + + return +} diff --git a/pkg/options/log.yaml b/pkg/options/log.yaml new file mode 100644 index 000000000..d1aea6ab1 --- /dev/null +++ b/pkg/options/log.yaml @@ -0,0 +1,49 @@ +props: + - name: debug + type: bool + description: | + Disables JSON format for logging and enables more human-readable output with colors. + + Disable for production. + + - name: level + default: "warn" + description: | + Minimum logging level. If set to "warn", + Levels warn, error, dpanic panic and fatal will be logged. + + Recommended value for production: warn + + Possible values: debug, info, warn, error, dpanic, panic, fatal + + - name: filter + description: | + Log filtering rules by level and name (log-level:log-namespace). + Please note that level (LOG_LEVEL) is applied before filter and it affects the final output! + + Leave unset for production. + + Example: + `warn+:* *:auth,workflow.*` + Log warnings, errors, panic, fatals. Everything from auth and workflow is logged. + + + See more examples and documentation here: https://github.com/moul/zapfilter + + - name: includeCaller + type: bool + default: false + description: | + Set to true to see where the logging was called from. + + Disable for production. + + - name: stacktraceLevel + default: "dpanic" + description: | + Include stack-trace when logging at a specified level or below. + Disable for production. + + Possible values: debug, info, warn, error, dpanic, panic, fatal + + diff --git a/vendor/modules.txt b/vendor/modules.txt index c4fa1a91b..f174eddff 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,5 @@ # cloud.google.com/go v0.67.0 cloud.google.com/go/compute/metadata -# github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 -## explicit # github.com/766b/chi-prometheus v0.0.0-20180509160047-46ac2b31aa30 ## explicit github.com/766b/chi-prometheus @@ -46,10 +44,6 @@ github.com/brianvoe/gofakeit/v6 github.com/brianvoe/gofakeit/v6/data # github.com/cespare/xxhash/v2 v2.1.1 github.com/cespare/xxhash/v2 -# github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4 -## explicit -# github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974 -## explicit # github.com/crewjam/httperr v0.0.0-20190612203328-a946449404da github.com/crewjam/httperr # github.com/crewjam/saml v0.4.5 @@ -236,8 +230,6 @@ github.com/markbates/goth/providers/linkedin github.com/markbates/goth/providers/openidConnect # github.com/mattermost/xml-roundtrip-validator v0.0.0-20201213122252-bcd7e1b9601e github.com/mattermost/xml-roundtrip-validator -# github.com/mattn/go-shellwords v1.0.12 -## explicit # github.com/mattn/go-sqlite3 v1.14.0 ## explicit github.com/mattn/go-sqlite3 @@ -266,8 +258,6 @@ github.com/mitchellh/reflectwalk # github.com/ngrok/sqlmw v0.0.0-20200129213757-d5c93a81bec6 ## explicit github.com/ngrok/sqlmw -# github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e -## explicit # github.com/pkg/errors v0.9.1 ## explicit github.com/pkg/errors @@ -332,8 +322,6 @@ github.com/stretchr/testify/require go.uber.org/atomic # go.uber.org/multierr v1.6.0 go.uber.org/multierr -# go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee -## explicit # go.uber.org/zap v1.19.0 ## explicit go.uber.org/zap @@ -504,11 +492,12 @@ gopkg.in/mail.v2 gopkg.in/square/go-jose.v2 gopkg.in/square/go-jose.v2/cipher gopkg.in/square/go-jose.v2/json -# gopkg.in/urfave/cli.v1 v1.20.0 -## explicit # gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ## explicit gopkg.in/yaml.v3 +# moul.io/zapfilter v1.6.1 +## explicit +moul.io/zapfilter # rsc.io/qr v0.2.0 ## explicit rsc.io/qr diff --git a/vendor/moul.io/zapfilter/.all-contributorsrc b/vendor/moul.io/zapfilter/.all-contributorsrc new file mode 100644 index 000000000..c72d68985 --- /dev/null +++ b/vendor/moul.io/zapfilter/.all-contributorsrc @@ -0,0 +1,37 @@ +{ + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "badgeTemplate": "[![All Contributors](https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg)](#contributors)", + "contributors": [ + { + "login": "moul", + "name": "Manfred Touron", + "avatar_url": "https://avatars1.githubusercontent.com/u/94029?v=4", + "profile": "http://manfred.life", + "contributions": [ + "maintenance", + "doc", + "test", + "code" + ] + }, + { + "login": "moul-bot", + "name": "moul-bot", + "avatar_url": "https://avatars1.githubusercontent.com/u/41326314?v=4", + "profile": "https://manfred.life/moul-bot", + "contributions": [ + "maintenance" + ] + } + ], + "contributorsPerLine": 7, + "projectName": "zapfilter", + "projectOwner": "moul", + "repoType": "github", + "repoHost": "https://github.com", + "skipCi": true +} diff --git a/vendor/moul.io/zapfilter/.dockerignore b/vendor/moul.io/zapfilter/.dockerignore new file mode 100644 index 000000000..e358cd716 --- /dev/null +++ b/vendor/moul.io/zapfilter/.dockerignore @@ -0,0 +1,35 @@ +## +## Specific to .dockerignore +## + +.git/ +Dockerfile +contrib/ + +## +## Common with .gitignore +## + +# Temporary files +*~ +*# +.#* + +# Vendors +node_modules/ +vendor/ + +# Binaries for programs and plugins +dist/ +gin-bin +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out diff --git a/vendor/moul.io/zapfilter/.editorconfig b/vendor/moul.io/zapfilter/.editorconfig new file mode 100644 index 000000000..d17f97d61 --- /dev/null +++ b/vendor/moul.io/zapfilter/.editorconfig @@ -0,0 +1,78 @@ +root = true + +[*] +charset = utf-8 + +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +indent_style = space +indent_size = 4 + +[*.mod] +indent_style = tab + +[{Makefile,**.mk}] +indent_style = tab + +[*.go] +indent_style = tab + +[*.css] +indent_size = 2 + +[*.proto] +indent_size = 2 + +[*.ftl] +indent_size = 2 + +[*.toml] +indent_size = 2 + +[*.swift] +indent_size = 4 + +[*.tmpl] +indent_size = 2 + +[*.js] +indent_size = 2 +block_comment_start = /* +block_comment_end = */ + +[*.{html,htm}] +indent_size = 2 + +[*.bat] +end_of_line = crlf + +[*.{yml,yaml}] +indent_size = 2 + +[*.json] +indent_size = 2 + +[.{babelrc,eslintrc,prettierrc}] +indent_size = 2 + +[{Fastfile,.buckconfig,BUCK}] +indent_size = 2 + +[*.diff] +indent_size = 1 + +[*.m] +indent_size = 1 +indent_style = space +block_comment_start = /** +block_comment = * +block_comment_end = */ + +[*.java] +indent_size = 4 +indent_style = space +block_comment_start = /** +block_comment = * +block_comment_end = */ diff --git a/vendor/moul.io/zapfilter/.gitattributes b/vendor/moul.io/zapfilter/.gitattributes new file mode 100644 index 000000000..8226a5e01 --- /dev/null +++ b/vendor/moul.io/zapfilter/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Collapse vendored and generated files on GitHub +AUTHORS linguist-generated +vendor/* linguist-vendored +rules.mk linguist-vendored +*/vendor/* linguist-vendored +*.gen.* linguist-generated +*.pb.go linguist-generated +*.pb.gw.go linguist-generated +go.sum linguist-generated +go.mod linguist-generated +gen.sum linguist-generated + +# Reduce conflicts on markdown files +*.md merge=union diff --git a/vendor/moul.io/zapfilter/.gitignore b/vendor/moul.io/zapfilter/.gitignore new file mode 100644 index 000000000..4edd5dec7 --- /dev/null +++ b/vendor/moul.io/zapfilter/.gitignore @@ -0,0 +1,32 @@ +go-test.json +.tmp/ + +# Temporary files +*~ +*# +.#* +coverage.txt + +go-build.log +go-install.log +go-test.json + +# Vendors +package-lock.json +node_modules/ +vendor/ + +# Binaries for programs and plugins +dist/ +gin-bin +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out diff --git a/vendor/moul.io/zapfilter/.golangci.yml b/vendor/moul.io/zapfilter/.golangci.yml new file mode 100644 index 000000000..c58127db1 --- /dev/null +++ b/vendor/moul.io/zapfilter/.golangci.yml @@ -0,0 +1,55 @@ +run: + deadline: 1m + tests: false + skip-files: + - "testing.go" + - ".*\\.pb\\.go" + - ".*\\.gen\\.go" + +linters-settings: + golint: + min-confidence: 0 + maligned: + suggest-new: true + goconst: + min-len: 5 + min-occurrences: 4 + misspell: + locale: US + +linters: + disable-all: true + enable: + - bodyclose + - deadcode + - depguard + - dogsled + - dupl + - errcheck + #- funlen + - gochecknoinits + #- gocognit + - goconst + - gocritic + - gocyclo + - gofmt + - goimports + - golint + - gosimple + - govet + - ineffassign + - interfacer + - maligned + - misspell + - nakedret + - prealloc + - scopelint + - staticcheck + - structcheck + #- stylecheck + - typecheck + - unconvert + - unparam + - unused + - varcheck + - whitespace diff --git a/vendor/moul.io/zapfilter/.releaserc.js b/vendor/moul.io/zapfilter/.releaserc.js new file mode 100644 index 000000000..566642fc0 --- /dev/null +++ b/vendor/moul.io/zapfilter/.releaserc.js @@ -0,0 +1,8 @@ +module.exports = { + branch: 'master', + plugins: [ + '@semantic-release/commit-analyzer', + '@semantic-release/release-notes-generator', + '@semantic-release/github', + ], +}; diff --git a/vendor/moul.io/zapfilter/AUTHORS b/vendor/moul.io/zapfilter/AUTHORS new file mode 100644 index 000000000..194149dbf --- /dev/null +++ b/vendor/moul.io/zapfilter/AUTHORS @@ -0,0 +1,4 @@ +# This file lists all individuals having contributed content to the repository. +# For how it is generated, see 'https://github.com/moul/rules.mk' + +Manfred Touron <94029+moul@users.noreply.github.com> diff --git a/vendor/moul.io/zapfilter/COPYRIGHT b/vendor/moul.io/zapfilter/COPYRIGHT new file mode 100644 index 000000000..a0ca6af7a --- /dev/null +++ b/vendor/moul.io/zapfilter/COPYRIGHT @@ -0,0 +1,22 @@ +Copyright 2020 Manfred Touron and other zapfilter Developers. + +Intellectual Property Notice +---------------------------- + +zapfilter is licensed under the Apache License, Version 2.0 +(see LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or +the MIT license (see LICENSE-MIT or http://opensource.org/licenses/MIT), +at your option. + +Copyrights and patents in the zapfilters project are retained +by contributors. +No copyright assignment is required to contribute to zapfilter. + + SPDX-License-Identifier: (Apache-2.0 OR MIT) + +SPDX usage +---------- + +Individual files may contain SPDX tags instead of the full license text. +This enables machine processing of license information based on the SPDX +License Identifiers that are available here: https://spdx.org/licenses/ diff --git a/vendor/moul.io/zapfilter/LICENSE-APACHE b/vendor/moul.io/zapfilter/LICENSE-APACHE new file mode 100644 index 000000000..9b5000b73 --- /dev/null +++ b/vendor/moul.io/zapfilter/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2020 Manfred Touron (manfred.life) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/moul.io/zapfilter/LICENSE-MIT b/vendor/moul.io/zapfilter/LICENSE-MIT new file mode 100644 index 000000000..9570e8eba --- /dev/null +++ b/vendor/moul.io/zapfilter/LICENSE-MIT @@ -0,0 +1,19 @@ +Copyright (c) 2020 Manfred Touron (manfred.life) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/moul.io/zapfilter/Makefile b/vendor/moul.io/zapfilter/Makefile new file mode 100644 index 000000000..b66b4a1d7 --- /dev/null +++ b/vendor/moul.io/zapfilter/Makefile @@ -0,0 +1,13 @@ +GOPKG ?= moul.io/zapfilter +DOCKER_IMAGE ?= moul/zapfilter +GOBINS ?= . +NPM_PACKAGES ?= . + +include rules.mk + +generate: + GO111MODULE=off go get github.com/campoy/embedmd + mkdir -p .tmp + go doc -all > .tmp/godoc.txt + embedmd -w README.md + rm -rf .tmp diff --git a/vendor/moul.io/zapfilter/README.md b/vendor/moul.io/zapfilter/README.md new file mode 100644 index 000000000..de2ec7f8a --- /dev/null +++ b/vendor/moul.io/zapfilter/README.md @@ -0,0 +1,224 @@ +# zapfilter + + ⚡💊 advanced filtering for uber's zap logger + +[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/moul.io/zapfilter) +[![License](https://img.shields.io/badge/license-Apache--2.0%20%2F%20MIT-%2397ca00.svg)](https://github.com/moul/zapfilter/blob/master/COPYRIGHT) +[![GitHub release](https://img.shields.io/github/release/moul/zapfilter.svg)](https://github.com/moul/zapfilter/releases) +[![Made by Manfred Touron](https://img.shields.io/badge/made%20by-Manfred%20Touron-blue.svg?style=flat)](https://manfred.life/) + +[![Go](https://github.com/moul/zapfilter/workflows/Go/badge.svg)](https://github.com/moul/zapfilter/actions?query=workflow%3AGo) +[![Release](https://github.com/moul/zapfilter/workflows/Release/badge.svg)](https://github.com/moul/zapfilter/actions?query=workflow%3ARelease) +[![PR](https://github.com/moul/zapfilter/workflows/PR/badge.svg)](https://github.com/moul/zapfilter/actions?query=workflow%3APR) +[![GolangCI](https://golangci.com/badges/github.com/moul/zapfilter.svg)](https://golangci.com/r/github.com/moul/zapfilter) +[![codecov](https://codecov.io/gh/moul/zapfilter/branch/master/graph/badge.svg)](https://codecov.io/gh/moul/zapfilter) +[![Go Report Card](https://goreportcard.com/badge/moul.io/zapfilter)](https://goreportcard.com/report/moul.io/zapfilter) +[![CodeFactor](https://www.codefactor.io/repository/github/moul/zapfilter/badge)](https://www.codefactor.io/repository/github/moul/zapfilter) + + +## Usage + +```go +import "moul.io/zapfilter" + +func ExampleParseRules() { + core := zap.NewExample().Core() + // *=myns => any level, myns namespace + // info,warn:myns.* => info or warn level, any namespace matching myns.* + // error=* => everything with error level + logger := zap.New(zapfilter.NewFilteringCore(core, zapfilter.MustParseRules("*:myns info,warn:myns.* error:*"))) + defer logger.Sync() + + logger.Debug("top debug") // no match + logger.Named("myns").Debug("myns debug") // matches *:myns + logger.Named("bar").Debug("bar debug") // no match + logger.Named("myns").Named("foo").Debug("myns.foo debug") // no match + + logger.Info("top info") // no match + logger.Named("myns").Info("myns info") // matches *:myns + logger.Named("bar").Info("bar info") // no match + logger.Named("myns").Named("foo").Info("myns.foo info") // matches info,warn:myns.* + + logger.Warn("top warn") // no match + logger.Named("myns").Warn("myns warn") // matches *:myns + logger.Named("bar").Warn("bar warn") // no match + logger.Named("myns").Named("foo").Warn("myns.foo warn") // matches info,warn:myns.* + + logger.Error("top error") // matches error:* + logger.Named("myns").Error("myns error") // matches *:myns and error:* + logger.Named("bar").Error("bar error") // matches error:* + logger.Named("myns").Named("foo").Error("myns.foo error") // matches error:* + + // Output: + // {"level":"debug","logger":"myns","msg":"myns debug"} + // {"level":"info","logger":"myns","msg":"myns info"} + // {"level":"info","logger":"myns.foo","msg":"myns.foo info"} + // {"level":"warn","logger":"myns","msg":"myns warn"} + // {"level":"warn","logger":"myns.foo","msg":"myns.foo warn"} + // {"level":"error","msg":"top error"} + // {"level":"error","logger":"myns","msg":"myns error"} + // {"level":"error","logger":"bar","msg":"bar error"} + // {"level":"error","logger":"myns.foo","msg":"myns.foo error"} +} +``` + +[embedmd]:# (.tmp/godoc.txt txt /FUNCTIONS/ $) +```txt +FUNCTIONS + +func CheckAnyLevel(logger *zap.Logger) bool + CheckAnyLevel determines whether at least one log level isn't filtered-out + by the logger. + +func NewFilteringCore(next zapcore.Core, filter FilterFunc) zapcore.Core + NewFilteringCore returns a core middleware that uses the given filter + function to determine whether to actually call Write on the next core in the + chain. + + +TYPES + +type FilterFunc func(zapcore.Entry, []zapcore.Field) bool + FilterFunc is used to check whether to filter the given entry and filters + out. + +func All(filters ...FilterFunc) FilterFunc + All checks if all filters return true. + +func Any(filters ...FilterFunc) FilterFunc + Any checks if any filter returns true. + +func ByLevels(pattern string) (FilterFunc, error) + ByLevels creates a FilterFunc based on a pattern. + + Level Patterns + + | Pattern | Debug | Info | Warn | Error | DPanic | Panic | Fatal | + | ------- | ----- | ---- | ---- | ----- | ------ | ----- | ----- | + | | X | X | X | X | X | X | X | + | * | X | X | X | X | x | X | X | + | debug | X | | | | | | | + | info | | X | | | | | | + | warn | | | X | | | | | + | error | | | | X | | | | + | dpanic | | | | | X | | | + | panic | | | | | | X | | + | fatal | | | | | | | X | + | debug+ | X | X | x | X | X | X | X | + | info+ | | X | X | X | X | X | X | + | warn+ | | | X | X | X | X | X | + | error+ | | | | X | X | X | X | + | dpanic+ | | | | | X | X | X | + | panic+ | | | | | | X | X | + | fatal+ | | | | | | | X | + +func ByNamespaces(input string) FilterFunc + ByNamespaces takes a list of patterns to filter out logs based on their + namespaces. Patterns are checked using path.Match. + +func ExactLevel(level zapcore.Level) FilterFunc + ExactLevel filters out entries with an invalid level. + +func MinimumLevel(level zapcore.Level) FilterFunc + MinimumLevel filters out entries with a too low level. + +func MustParseRules(pattern string) FilterFunc + MustParseRules calls ParseRules and panics if initialization failed. + +func ParseRules(pattern string) (FilterFunc, error) + ParseRules takes a CLI-friendly set of rules to construct a filter. + + Syntax + + pattern: RULE [RULE...] + RULE: one of: + - LEVELS:NAMESPACES + - NAMESPACES + LEVELS: LEVEL,[,LEVEL] + LEVEL: see `Level Patterns` + NAMESPACES: NAMESPACE[,NAMESPACE] + NAMESPACE: one of: + - namespace // should be exactly this namespace + - *mat*ch* // should match + - -NAMESPACE // should not match + + Examples + + * everything + *:* everything + info:* level info; any namespace + info+:* levels info, warn, error, dpanic, panic, and fatal; any namespace + info,warn:* levels info, warn; any namespace + ns1 any level; namespace 'ns1' + *:ns1 any level; namespace 'ns1' + ns1* any level; namespaces matching 'ns1*' + *:ns1* any level; namespaces matching 'ns1*' + *:ns1,ns2 any level; namespaces 'ns1' and 'ns2' + *:ns*,-ns3* any level; namespaces matching 'ns*' but not matching 'ns3*' + info:ns1 level info; namespace 'ns1' + info,warn:ns1,ns2 levels info and warn; namespaces 'ns1' and 'ns2' + info:ns1 warn:n2 level info + namespace 'ns1' OR level warn and namespace 'ns2' + info,warn:myns* error+:* levels info or warn and namespaces matching 'myns*' OR levels error, dpanic, panic or fatal for any namespace + +func Reverse(filter FilterFunc) FilterFunc + Reverse checks is the passed filter returns false. + +``` + +More examples on https://pkg.go.dev/moul.io/zapfilter + +## Install + +### Using go + +```console +$ go get -u moul.io/zapfilter +``` + +### Releases + +See https://github.com/moul/zapfilter/releases + +## Contribute + +![Contribute <3](https://raw.githubusercontent.com/moul/moul/master/contribute.gif) + +I really welcome contributions. Your input is the most precious material. I'm well aware of that and I thank you in advance. Everyone is encouraged to look at what they can do on their own scale; no effort is too small. + +Everything on contribution is sum up here: [CONTRIBUTING.md](./CONTRIBUTING.md) + +### Contributors ✨ + + +[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg)](#contributors) + + +Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + +

Manfred Touron

🚧 📖 ⚠️ 💻

moul-bot

🚧
+ + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! + +### Stargazers over time + +[![Stargazers over time](https://starchart.cc/moul/zapfilter.svg)](https://starchart.cc/moul/zapfilter) + +## License + +© 2020 [Manfred Touron](https://manfred.life) + +Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) ([`LICENSE-APACHE`](LICENSE-APACHE)) or the [MIT license](https://opensource.org/licenses/MIT) ([`LICENSE-MIT`](LICENSE-MIT)), at your option. See the [`COPYRIGHT`](COPYRIGHT) file for more details. + +`SPDX-License-Identifier: (Apache-2.0 OR MIT)` diff --git a/vendor/moul.io/zapfilter/doc.go b/vendor/moul.io/zapfilter/doc.go new file mode 100644 index 000000000..3867671bd --- /dev/null +++ b/vendor/moul.io/zapfilter/doc.go @@ -0,0 +1,29 @@ +// Copyright © 2020 Manfred Touron +// SPDX-License-Identifier: Apache-2.0 OR MIT + +// message from the author: +// +--------------------------------------------------------------+ +// | * * * ░░░░░░░░░░░░░░░░░░░░ Hello ░░░░░░░░░░░░░░░░░░░░░░░░░░| +// +--------------------------------------------------------------+ +// | | +// | ++ ______________________________________ | +// | ++++ / \ | +// | ++++ | | | +// | ++++++++++ | Feel free to contribute to this | | +// | +++ | | project or contact me on | | +// | ++ | | manfred.life if you like this | | +// | + -== ==| | project! | | +// | ( <*> <*> | | | +// | | | /| :) | | +// | | _) / | | | +// | | +++ / \______________________________________/ | +// | \ =+ / | +// | \ + | +// | |\++++++ | +// | | ++++ ||// | +// | ___| |___ _||/__ __| +// | / --- \ \| ||| __ _ ___ __ __/ /| +// |/ | | \ \ / / ' \/ _ \/ // / / | +// || | | | | | /_/_/_/\___/\_,_/_/ | +// +--------------------------------------------------------------+ +package zapfilter // import "moul.io/zapfilter" diff --git a/vendor/moul.io/zapfilter/go.mod b/vendor/moul.io/zapfilter/go.mod new file mode 100644 index 000000000..95fa43809 --- /dev/null +++ b/vendor/moul.io/zapfilter/go.mod @@ -0,0 +1,8 @@ +module moul.io/zapfilter + +go 1.13 + +require ( + github.com/stretchr/testify v1.4.0 + go.uber.org/zap v1.16.0 +) diff --git a/vendor/moul.io/zapfilter/go.sum b/vendor/moul.io/zapfilter/go.sum new file mode 100644 index 000000000..380fb9de0 --- /dev/null +++ b/vendor/moul.io/zapfilter/go.sum @@ -0,0 +1,55 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM= +go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/vendor/moul.io/zapfilter/package.json b/vendor/moul.io/zapfilter/package.json new file mode 100644 index 000000000..b9e8ccee0 --- /dev/null +++ b/vendor/moul.io/zapfilter/package.json @@ -0,0 +1,21 @@ +{ + "_comment": "this project is not a node.js one, package.json is just used to define some metadata", + "name": "@moul.io/zapfilter", + "version": "0.0.1", + "author": "Manfred Touron (https://manfred.life)", + "contributors": [ + "Manfred Touron (https://manfred.life)" + ], + "license": "(Apache-2.0 OR MIT)", + "scripts": { + "start": "zapfilter", + "install": "make install", + "test": "make test" + }, + "repository": { + "type": "git", + "url": "https://github.com/moul/zapfilter.git" + }, + "bugs": "https://github.com/moul/zapfilter/issues", + "homepage": "https://moul.io/zapfilter" +} diff --git a/vendor/moul.io/zapfilter/rules.mk b/vendor/moul.io/zapfilter/rules.mk new file mode 100644 index 000000000..19f076751 --- /dev/null +++ b/vendor/moul.io/zapfilter/rules.mk @@ -0,0 +1,318 @@ +# +--------------------------------------------------------------+ +# | * * * moul.io/rules.mk | +# +--------------------------------------------------------------+ +# | | +# | ++ ______________________________________ | +# | ++++ / \ | +# | ++++ | | | +# | ++++++++++ | https://moul.io/rules.mk is a set | | +# | +++ | | of common Makefile rules that can | | +# | ++ | | be configured from the Makefile | | +# | + -== ==| | or with environment variables. | | +# | ( <*> <*> | | | +# | | | /| Manfred Touron | | +# | | _) / | manfred.life | | +# | | +++ / \______________________________________/ | +# | \ =+ / | +# | \ + | +# | |\++++++ | +# | | ++++ ||// | +# | ___| |___ _||/__ __| +# | / --- \ \| ||| __ _ ___ __ __/ /| +# |/ | | \ \ / / ' \/ _ \/ // / / | +# || | | | | | /_/_/_/\___/\_,_/_/ | +# +--------------------------------------------------------------+ + +all: help + +## +## Common helpers +## + +rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) + +## +## rules.mk +## +ifneq ($(wildcard rules.mk),) +.PHONY: rulesmk.bumpdeps +rulesmk.bumpdeps: + wget -O rules.mk https://raw.githubusercontent.com/moul/rules.mk/master/rules.mk +BUMPDEPS_STEPS += rulesmk.bumpdeps +endif + +## +## Maintainer +## + +ifneq ($(wildcard .git/HEAD),) +.PHONY: generate.authors +generate.authors: AUTHORS +AUTHORS: .git/ + echo "# This file lists all individuals having contributed content to the repository." > AUTHORS + echo "# For how it is generated, see 'https://github.com/moul/rules.mk'" >> AUTHORS + echo >> AUTHORS + git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf >> AUTHORS +GENERATE_STEPS += generate.authors +endif + +## +## Golang +## + +ifndef GOPKG +ifneq ($(wildcard go.mod),) +GOPKG = $(shell sed '/module/!d;s/^omdule\ //' go.mod) +endif +endif +ifdef GOPKG +GO ?= go +GOPATH ?= $(HOME)/go +GO_INSTALL_OPTS ?= +GO_TEST_OPTS ?= -test.timeout=30s +GOMOD_DIR ?= . +GOCOVERAGE_FILE ?= ./coverage.txt +GOTESTJSON_FILE ?= ./go-test.json +GOBUILDLOG_FILE ?= ./go-build.log +GOINSTALLLOG_FILE ?= ./go-install.log + +ifdef GOBINS +.PHONY: go.install +go.install: +ifeq ($(CI),true) + @rm -f /tmp/goinstall.log + @set -e; for dir in $(GOBINS); do ( set -xe; \ + cd $$dir; \ + $(GO) install -v $(GO_INSTALL_OPTS) .; \ + ); done 2>&1 | tee $(GOINSTALLLOG_FILE) + +else + @set -e; for dir in $(GOBINS); do ( set -xe; \ + cd $$dir; \ + $(GO) install $(GO_INSTALL_OPTS) .; \ + ); done +endif +INSTALL_STEPS += go.install + +.PHONY: go.release +go.release: + goreleaser --snapshot --skip-publish --rm-dist + @echo -n "Do you want to release? [y/N] " && read ans && \ + if [ $${ans:-N} = y ]; then set -xe; goreleaser --rm-dist; fi +RELEASE_STEPS += go.release +endif + +.PHONY: go.unittest +go.unittest: +ifeq ($(CI),true) + @echo "mode: atomic" > /tmp/gocoverage + @rm -f $(GOTESTJSON_FILE) + @set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do (set -e; (set -euf pipefail; \ + cd $$dir; \ + ($(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race -json | tee -a $(GOTESTJSON_FILE) 3>&1 1>&2 2>&3 | tee -a $(GOBUILDLOG_FILE); \ + ); \ + if [ -f /tmp/profile.out ]; then \ + cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \ + rm -f /tmp/profile.out; \ + fi)); done + @mv /tmp/gocoverage $(GOCOVERAGE_FILE) +else + @echo "mode: atomic" > /tmp/gocoverage + @set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do (set -e; (set -xe; \ + cd $$dir; \ + $(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race); \ + if [ -f /tmp/profile.out ]; then \ + cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \ + rm -f /tmp/profile.out; \ + fi); done + @mv /tmp/gocoverage $(GOCOVERAGE_FILE) +endif + +.PHONY: go.checkdoc +go.checkdoc: + go doc $(GOMOD_DIR) + +.PHONY: go.coverfunc +go.coverfunc: go.unittest + go tool cover -func=$(GOCOVERAGE_FILE) | grep -v .pb.go: | grep -v .pb.gw.go: + +.PHONY: go.lint +go.lint: + @set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + golangci-lint run --verbose ./...; \ + ); done + +.PHONY: go.tidy +go.tidy: + @set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + $(GO) mod tidy; \ + ); done + +.PHONY: go.build +go.build: + @set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + $(GO) build ./...; \ + ); done + +.PHONY: go.bump-deps +go.bumpdeps: + @set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + $(GO) get -u ./...; \ + ); done + +.PHONY: go.bump-deps +go.fmt: + if ! command -v goimports &>/dev/null; then GO111MODULE=off go get golang.org/x/tools/cmd/goimports; fi + @set -e; for dir in `find $(GOMOD_DIR) -type f -name "go.mod" | grep -v /vendor/ | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \ + cd $$dir; \ + goimports -w `go list -f '{{.Dir}}' ./...)` \ + ); done + +BUILD_STEPS += go.build +BUMPDEPS_STEPS += go.bumpdeps +TIDY_STEPS += go.tidy +LINT_STEPS += go.lint +UNITTEST_STEPS += go.unittest +FMT_STEPS += go.fmt +endif + +## +## Gitattributes +## + +ifneq ($(wildcard .gitattributes),) +.PHONY: _linguist-ignored +_linguist-kept: + @git check-attr linguist-vendored $(shell git check-attr linguist-generated $(shell find . -type f | grep -v .git/) | grep unspecified | cut -d: -f1) | grep unspecified | cut -d: -f1 | sort + +.PHONY: _linguist-kept +_linguist-ignored: + @git check-attr linguist-vendored linguist-ignored `find . -not -path './.git/*' -type f` | grep '\ set$$' | cut -d: -f1 | sort -u +endif + +## +## Node +## + +ifndef NPM_PACKAGES +ifneq ($(wildcard package.json),) +NPM_PACKAGES = . +endif +endif +ifdef NPM_PACKAGES +.PHONY: npm.publish +npm.publish: + @echo -n "Do you want to npm publish? [y/N] " && read ans && \ + @if [ $${ans:-N} = y ]; then \ + set -e; for dir in $(NPM_PACKAGES); do ( set -xe; \ + cd $$dir; \ + npm publish --access=public; \ + ); done; \ + fi +RELEASE_STEPS += npm.publish +endif + +## +## Docker +## + +docker_build = docker build \ + --build-arg VCS_REF=`git rev-parse --short HEAD` \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg VERSION=`git describe --tags --always` \ + -t "$2" -f "$1" "$(dir $1)" + +ifndef DOCKERFILE_PATH +DOCKERFILE_PATH = ./Dockerfile +endif +ifndef DOCKER_IMAGE +ifneq ($(wildcard Dockerfile),) +DOCKER_IMAGE = $(notdir $(PWD)) +endif +endif +ifdef DOCKER_IMAGE +ifneq ($(DOCKER_IMAGE),none) +.PHONY: docker.build +docker.build: + $(call docker_build,$(DOCKERFILE_PATH),$(DOCKER_IMAGE)) + +BUILD_STEPS += docker.build +endif +endif + +## +## Common +## + +TEST_STEPS += $(UNITTEST_STEPS) +TEST_STEPS += $(LINT_STEPS) +TEST_STEPS += $(TIDY_STEPS) + +ifneq ($(strip $(TEST_STEPS)),) +.PHONY: test +test: $(PRE_TEST_STEPS) $(TEST_STEPS) +endif + +ifdef INSTALL_STEPS +.PHONY: install +install: $(PRE_INSTALL_STEPS) $(INSTALL_STEPS) +endif + +ifdef UNITTEST_STEPS +.PHONY: unittest +unittest: $(PRE_UNITTEST_STEPS) $(UNITTEST_STEPS) +endif + +ifdef LINT_STEPS +.PHONY: lint +lint: $(PRE_LINT_STEPS) $(FMT_STEPS) $(LINT_STEPS) +endif + +ifdef TIDY_STEPS +.PHONY: tidy +tidy: $(PRE_TIDY_STEPS) $(TIDY_STEPS) +endif + +ifdef BUILD_STEPS +.PHONY: build +build: $(PRE_BUILD_STEPS) $(BUILD_STEPS) +endif + +ifdef RELEASE_STEPS +.PHONY: release +release: $(PRE_RELEASE_STEPS) $(RELEASE_STEPS) +endif + +ifdef BUMPDEPS_STEPS +.PHONY: bumpdeps +bumpdeps: $(PRE_BUMDEPS_STEPS) $(BUMPDEPS_STEPS) +endif + +ifdef FMT_STEPS +.PHONY: fmt +fmt: $(PRE_FMT_STEPS) $(FMT_STEPS) +endif + +ifdef GENERATE_STEPS +.PHONY: generate +generate: $(PRE_GENERATE_STEPS) $(GENERATE_STEPS) +endif + +.PHONY: help +help:: + @echo "General commands:" + @[ "$(BUILD_STEPS)" != "" ] && echo " build" || true + @[ "$(BUMPDEPS_STEPS)" != "" ] && echo " bumpdeps" || true + @[ "$(FMT_STEPS)" != "" ] && echo " fmt" || true + @[ "$(GENERATE_STEPS)" != "" ] && echo " generate" || true + @[ "$(INSTALL_STEPS)" != "" ] && echo " install" || true + @[ "$(LINT_STEPS)" != "" ] && echo " lint" || true + @[ "$(RELEASE_STEPS)" != "" ] && echo " release" || true + @[ "$(TEST_STEPS)" != "" ] && echo " test" || true + @[ "$(TIDY_STEPS)" != "" ] && echo " tidy" || true + @[ "$(UNITTEST_STEPS)" != "" ] && echo " unittest" || true + @# FIXME: list other commands diff --git a/vendor/moul.io/zapfilter/zapfilter.go b/vendor/moul.io/zapfilter/zapfilter.go new file mode 100644 index 000000000..f948c1ade --- /dev/null +++ b/vendor/moul.io/zapfilter/zapfilter.go @@ -0,0 +1,388 @@ +package zapfilter + +import ( + "fmt" + "path" + "strings" + "sync" + + "go.uber.org/zap" + "go.uber.org/zap/zapcore" +) + +// FilterFunc is used to check whether to filter the given entry and filters out. +type FilterFunc func(zapcore.Entry, []zapcore.Field) bool + +// NewFilteringCore returns a core middleware that uses the given filter function to +// determine whether to actually call Write on the next core in the chain. +func NewFilteringCore(next zapcore.Core, filter FilterFunc) zapcore.Core { + if filter == nil { + filter = alwaysFalseFilter + } + return &filteringCore{next, filter} +} + +// CheckAnyLevel determines whether at least one log level isn't filtered-out by the logger. +func CheckAnyLevel(logger *zap.Logger) bool { + for _, level := range allLevels { + if level >= zapcore.PanicLevel { + continue // panic and fatal cannot be skipped + } + if logger.Check(level, "") != nil { + return true + } + } + return false +} + +type filteringCore struct { + next zapcore.Core + filter FilterFunc +} + +// Check determines whether the supplied zapcore.Entry should be logged. +// If the entry should be logged, the filteringCore adds itself to the zapcore.CheckedEntry +// and returns the results. +func (core *filteringCore) Check(entry zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry { + // FIXME: consider calling downstream core.Check too, but need to document how to + // properly set logging level. + if core.filter(entry, nil) { + ce = ce.AddCore(entry, core) + } + return ce +} + +// Write determines whether the supplied zapcore.Entry with provided []zapcore.Field should +// be logged, then calls the wrapped zapcore.Write. +func (core *filteringCore) Write(entry zapcore.Entry, fields []zapcore.Field) error { + if !core.filter(entry, fields) { + return nil + } + return core.next.Write(entry, fields) +} + +// With adds structured context to the wrapped zapcore.Core. +func (core *filteringCore) With(fields []zapcore.Field) zapcore.Core { + return &filteringCore{ + next: core.next.With(fields), + filter: core.filter, + } +} + +// Enabled asks the wrapped zapcore.Core to decide whether a given logging level is enabled +// when logging a message. +func (core *filteringCore) Enabled(level zapcore.Level) bool { + // FIXME: Maybe it's better to always return true and only rely on the Check() func? + // Another way to consider it is to keep the smaller log level configured on + // zapfilter. + return core.next.Enabled(level) +} + +// Sync flushed buffered logs (if any). +func (core *filteringCore) Sync() error { + return core.next.Sync() +} + +// ByNamespaces takes a list of patterns to filter out logs based on their namespaces. +// Patterns are checked using path.Match. +func ByNamespaces(input string) FilterFunc { + if input == "" { + return alwaysFalseFilter + } + patterns := strings.Split(input, ",") + + // edge case optimization (always true) + { + hasIncludeWildcard := false + hasExclude := false + for _, pattern := range patterns { + if pattern == "" { + continue + } + if pattern == "*" { + hasIncludeWildcard = true + } + if pattern[0] == '-' { + hasExclude = true + } + } + if hasIncludeWildcard && !hasExclude { + return alwaysTrueFilter + } + } + + var mutex sync.Mutex + matchMap := map[string]bool{} + return func(entry zapcore.Entry, fields []zapcore.Field) bool { + mutex.Lock() + defer mutex.Unlock() + + if _, found := matchMap[entry.LoggerName]; !found { + matchMap[entry.LoggerName] = false + matchInclude := false + matchExclude := false + for _, pattern := range patterns { + switch { + case pattern[0] == '-' && !matchExclude: + if matched, _ := path.Match(pattern[1:], entry.LoggerName); matched { + matchExclude = true + } + case pattern[0] != '-' && !matchInclude: + if matched, _ := path.Match(pattern, entry.LoggerName); matched { + matchInclude = true + } + } + } + matchMap[entry.LoggerName] = matchInclude && !matchExclude + } + return matchMap[entry.LoggerName] + } +} + +// ExactLevel filters out entries with an invalid level. +func ExactLevel(level zapcore.Level) FilterFunc { + return func(entry zapcore.Entry, fields []zapcore.Field) bool { + return entry.Level == level + } +} + +// MinimumLevel filters out entries with a too low level. +func MinimumLevel(level zapcore.Level) FilterFunc { + return func(entry zapcore.Entry, fields []zapcore.Field) bool { + return entry.Level >= level + } +} + +// Any checks if any filter returns true. +func Any(filters ...FilterFunc) FilterFunc { + return func(entry zapcore.Entry, fields []zapcore.Field) bool { + for _, filter := range filters { + if filter == nil { + continue + } + if filter(entry, fields) { + return true + } + } + return false + } +} + +// Reverse checks is the passed filter returns false. +func Reverse(filter FilterFunc) FilterFunc { + return func(entry zapcore.Entry, fields []zapcore.Field) bool { + return !filter(entry, fields) + } +} + +// All checks if all filters return true. +func All(filters ...FilterFunc) FilterFunc { + return func(entry zapcore.Entry, fields []zapcore.Field) bool { + var atLeastOneSuccessful bool + for _, filter := range filters { + if filter == nil { + continue + } + if !filter(entry, fields) { + return false + } + atLeastOneSuccessful = true + } + return atLeastOneSuccessful + } +} + +// ParseRules takes a CLI-friendly set of rules to construct a filter. +// +// Syntax +// +// pattern: RULE [RULE...] +// RULE: one of: +// - LEVELS:NAMESPACES +// - NAMESPACES +// LEVELS: LEVEL,[,LEVEL] +// LEVEL: see `Level Patterns` +// NAMESPACES: NAMESPACE[,NAMESPACE] +// NAMESPACE: one of: +// - namespace // should be exactly this namespace +// - *mat*ch* // should match +// - -NAMESPACE // should not match +// +// Examples +// +// * everything +// *:* everything +// info:* level info; any namespace +// info+:* levels info, warn, error, dpanic, panic, and fatal; any namespace +// info,warn:* levels info, warn; any namespace +// ns1 any level; namespace 'ns1' +// *:ns1 any level; namespace 'ns1' +// ns1* any level; namespaces matching 'ns1*' +// *:ns1* any level; namespaces matching 'ns1*' +// *:ns1,ns2 any level; namespaces 'ns1' and 'ns2' +// *:ns*,-ns3* any level; namespaces matching 'ns*' but not matching 'ns3*' +// info:ns1 level info; namespace 'ns1' +// info,warn:ns1,ns2 levels info and warn; namespaces 'ns1' and 'ns2' +// info:ns1 warn:n2 level info + namespace 'ns1' OR level warn and namespace 'ns2' +// info,warn:myns* error+:* levels info or warn and namespaces matching 'myns*' OR levels error, dpanic, panic or fatal for any namespace +func ParseRules(pattern string) (FilterFunc, error) { + var topFilter FilterFunc + + // rules are separated by spaces, tabs or \n + for _, rule := range strings.Fields(pattern) { + // split rule into parts (separated by ':') + rule = strings.TrimSpace(rule) + if rule == "" { + continue + } + parts := strings.SplitN(rule, ":", 2) + var left, right string + switch len(parts) { + case 1: + // if no separator, left stays empty + right = parts[0] + case 2: + if parts[0] == "" || parts[1] == "" { + return nil, fmt.Errorf("bad syntax") + } + left = parts[0] + right = parts[1] + default: + return nil, fmt.Errorf("bad syntax") + } + + levelFilter, err := ByLevels(left) + if err != nil { + return nil, err + } + namespaceFilter := ByNamespaces(right) + topFilter = Any(topFilter, All(levelFilter, namespaceFilter)) + } + + return topFilter, nil +} + +// ByLevels creates a FilterFunc based on a pattern. +// +// Level Patterns +// | Pattern | Debug | Info | Warn | Error | DPanic | Panic | Fatal | +// | ------- | ----- | ---- | ---- | ----- | ------ | ----- | ----- | +// | | X | X | X | X | X | X | X | +// | * | X | X | X | X | x | X | X | +// | debug | X | | | | | | | +// | info | | X | | | | | | +// | warn | | | X | | | | | +// | error | | | | X | | | | +// | dpanic | | | | | X | | | +// | panic | | | | | | X | | +// | fatal | | | | | | | X | +// | debug+ | X | X | x | X | X | X | X | +// | info+ | | X | X | X | X | X | X | +// | warn+ | | | X | X | X | X | X | +// | error+ | | | | X | X | X | X | +// | dpanic+ | | | | | X | X | X | +// | panic+ | | | | | | X | X | +// | fatal+ | | | | | | | X | +func ByLevels(pattern string) (FilterFunc, error) { + // parse pattern + var enabled uint + for _, part := range strings.Split(pattern, ",") { + switch strings.ToLower(part) { + case "", "*", "debug+": + enabled |= debugLevel | infoLevel | warnLevel | errorLevel | dpanicLevel | panicLevel | fatalLevel + case "debug": + enabled |= debugLevel + case "info": + enabled |= infoLevel + case "info+": + enabled |= infoLevel | warnLevel | errorLevel | dpanicLevel | panicLevel | fatalLevel + case "warn": + enabled |= warnLevel + case "warn+": + enabled |= warnLevel | errorLevel | dpanicLevel | panicLevel | fatalLevel + case "error": + enabled |= errorLevel + case "error+": + enabled |= errorLevel | dpanicLevel | panicLevel | fatalLevel + case "dpanic": + enabled |= dpanicLevel + case "dpanic+": + enabled |= dpanicLevel | panicLevel | fatalLevel + case "panic": + enabled |= panicLevel + case "panic+": + enabled |= panicLevel | fatalLevel + case "fatal", "fatal+": + enabled |= fatalLevel + default: + return nil, fmt.Errorf("unsupported keyword: %q", pattern) + } + } + + // if everything is enabled + if enabled == debugLevel&infoLevel&warnLevel&errorLevel&dpanicLevel&panicLevel&fatalLevel { + return alwaysTrueFilter, nil + } + + // construct custom filter + var filter FilterFunc + if enabled&debugLevel != 0 { + filter = Any(ExactLevel(zapcore.DebugLevel), filter) + } + if enabled&infoLevel != 0 { + filter = Any(ExactLevel(zapcore.InfoLevel), filter) + } + if enabled&warnLevel != 0 { + filter = Any(ExactLevel(zapcore.WarnLevel), filter) + } + if enabled&errorLevel != 0 { + filter = Any(ExactLevel(zapcore.ErrorLevel), filter) + } + if enabled&dpanicLevel != 0 { + filter = Any(ExactLevel(zapcore.DPanicLevel), filter) + } + if enabled&panicLevel != 0 { + filter = Any(ExactLevel(zapcore.PanicLevel), filter) + } + if enabled&fatalLevel != 0 { + filter = Any(ExactLevel(zapcore.FatalLevel), filter) + } + return filter, nil +} + +const ( + debugLevel uint = 1 << iota + infoLevel + warnLevel + errorLevel + dpanicLevel + panicLevel + fatalLevel +) + +// MustParseRules calls ParseRules and panics if initialization failed. +func MustParseRules(pattern string) FilterFunc { + filter, err := ParseRules(pattern) + if err != nil { + panic(err) + } + return filter +} + +func alwaysFalseFilter(_ zapcore.Entry, _ []zapcore.Field) bool { + return false +} + +func alwaysTrueFilter(_ zapcore.Entry, _ []zapcore.Field) bool { + return true +} + +var allLevels = []zapcore.Level{ + zapcore.DebugLevel, + zapcore.InfoLevel, + zapcore.WarnLevel, + zapcore.ErrorLevel, + zapcore.DPanicLevel, + zapcore.PanicLevel, + zapcore.FatalLevel, +}