Skip to content

Commit 007da0b

Browse files
committed
dep updates
fixed golangci-lint tool install, and go fmts
1 parent 18f5418 commit 007da0b

File tree

12 files changed

+172
-140
lines changed

12 files changed

+172
-140
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ update:
4848
tools:
4949
# installs tools used during build
5050
go get -u golang.org/x/tools/cmd/cover
51-
sh -c "$$(wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh || echo exit 2)" -- -b $(shell go env GOPATH)/bin $(GOLANGCI_LINT_VERSION)
51+
sh -c "$$(wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh || echo exit 2)" -- -b $(shell go env GOPATH)/bin $(GOLANGCI_LINT_VERSION)
5252

5353
.PHONY: all build builddir run artifacts vet lint clean fmt test testall testreport up down pull builder runc ci bash fish image prep vendor.update vendor.ensure tools buildtools migratetool db.migrate
5454

config.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ var DefaultConfigEnvVars = []string{"FLUME"}
1616
// ConfigFromEnv configures flume from environment variables.
1717
// It should be called from main():
1818
//
19-
// func main() {
20-
// flume.ConfigFromEnv()
21-
// ...
22-
// }
19+
// func main() {
20+
// flume.ConfigFromEnv()
21+
// ...
22+
// }
2323
//
2424
// It searches envvars for the first environment
2525
// variable that is set, and attempts to parse the value.
@@ -30,7 +30,6 @@ var DefaultConfigEnvVars = []string{"FLUME"}
3030
// fails, an error is printed to stdout, and the error is returned.
3131
//
3232
// If envvars is empty, it defaults to DefaultConfigEnvVars.
33-
//
3433
func ConfigFromEnv(envvars ...string) error {
3534
if len(envvars) == 0 {
3635
envvars = DefaultConfigEnvVars
@@ -58,11 +57,11 @@ func ConfigFromEnv(envvars ...string) error {
5857
// Configs can be unmarshaled from JSON, making it a convenient
5958
// way to configure most logging options from env vars or files, i.e.:
6059
//
61-
// err := flume.ConfigString(os.Getenv("flume"))
60+
// err := flume.ConfigString(os.Getenv("flume"))
6261
//
6362
// Configs can be created and applied programmatically:
6463
//
65-
// err := flume.Configure(flume.Config{})
64+
// err := flume.Configure(flume.Config{})
6665
//
6766
// Defaults are appropriate for a JSON encoded production logger:
6867
//
@@ -74,13 +73,13 @@ func ConfigFromEnv(envvars ...string) error {
7473
// An alternate set of defaults, more appropriate for development environments,
7574
// can be configured with `Config{Development:true}`:
7675
//
77-
// err := flume.Configure(flume.Config{Development:true})
76+
// err := flume.Configure(flume.Config{Development:true})
7877
//
7978
// - colorized terminal encoder
8079
// - short timestamps
8180
// - call sites are logged
8281
//
83-
// err := flume.Configure(flume.Config{Development:true})
82+
// err := flume.Configure(flume.Config{Development:true})
8483
//
8584
// Any of the other configuration options can be specified to override
8685
// the defaults.
@@ -185,19 +184,17 @@ func NewDevelopmentEncoderConfig() *EncoderConfig {
185184
// as a simple time of day, without a date. Intended for development and testing.
186185
// Not good in a production system, where you probably need to know the date.
187186
//
188-
// encConfig := flume.EncoderConfig{}
189-
// encConfig.EncodeTime = flume.JustTimeEncoder
190-
//
187+
// encConfig := flume.EncoderConfig{}
188+
// encConfig.EncodeTime = flume.JustTimeEncoder
191189
func JustTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
192190
enc.AppendString(t.Format("15:04:05.000"))
193191
}
194192

195193
// AbbrLevelEncoder encodes logging levels to the strings in the log entries.
196194
// Encodes levels as 3-char abbreviations in upper case.
197195
//
198-
// encConfig := flume.EncoderConfig{}
199-
// encConfig.EncodeTime = flume.AbbrLevelEncoder
200-
//
196+
// encConfig := flume.EncoderConfig{}
197+
// encConfig.EncodeTime = flume.AbbrLevelEncoder
201198
func AbbrLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder) {
202199
switch l {
203200
case zapcore.DebugLevel:

console_encoder.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ func NewConsoleEncoder(cfg *EncoderConfig) Encoder {
8787
//
8888
// `github.com/mgutz/ansi` is a convenient package for getting color codes, e.g.:
8989
//
90-
// ansi.ColorCode("red")
91-
//
90+
// ansi.ColorCode("red")
9291
func NewColorizedConsoleEncoder(cfg *EncoderConfig, colorizer Colorizer) Encoder {
9392
e := NewConsoleEncoder(cfg).(*consoleEncoder)
9493
e.colorizer = colorizer

core.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ func (l *Core) IsInfo() bool {
238238
//
239239
// args should be alternative keys and values. keys should be strings.
240240
//
241-
// reqLogger := l.With("requestID", reqID)
242-
//
241+
// reqLogger := l.With("requestID", reqID)
243242
func (l *Core) With(args ...interface{}) Logger {
244243
return l.WithArgs(args...)
245244
}

doc.go

Lines changed: 83 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11,106 +11,120 @@
1111
// importers can entirely replace flume if they wish. Alternately, importers can use flume to configure
1212
// the library's log output, and/or redirect it into the overall program's log stream.
1313
//
14-
// Logging
14+
// # Logging
1515
//
1616
// This package does not offer package level log functions, so you need to create a logger instance first:
1717
// A common pattern is to create a single, package-wide logger, named after the package:
1818
//
19-
// var log = flume.New("mypkg")
19+
// var log = flume.New("mypkg")
2020
//
2121
// Then, write some logs:
2222
//
23-
// log.Debug("created user", "username", "frank", "role", "admin")
23+
// log.Debug("created user", "username", "frank", "role", "admin")
2424
//
2525
// Logs have a message, then matched pairs of key/value properties. Child loggers can be created
2626
// and pre-seeded with a set of properties:
2727
//
28-
// reqLogger := log.With("remoteAddr", req.RemoteAddr)
28+
// reqLogger := log.With("remoteAddr", req.RemoteAddr)
2929
//
3030
// Expensive log events can be avoid by explicitly checking level:
3131
//
32-
// if log.IsDebug() {
33-
// log.Debug("created resource", "resource", resource.ExpensiveToString())
34-
// }
32+
// if log.IsDebug() {
33+
// log.Debug("created resource", "resource", resource.ExpensiveToString())
34+
// }
3535
//
3636
// Loggers can be bound to context.Context, which is convenient for carrying
3737
// per-transaction loggers (pre-seeded with transaction specific context) through layers of request
3838
// processing code:
3939
//
40-
// ctx = flume.WithLogger(ctx, log.With("transactionID", tid))
41-
// // ...later...
42-
// flume.FromContext(ctx).Info("Request handled.")
40+
// ctx = flume.WithLogger(ctx, log.With("transactionID", tid))
41+
// // ...later...
42+
// flume.FromContext(ctx).Info("Request handled.")
4343
//
4444
// The standard Logger interface only supports 3 levels of log, DBG, INF, and ERR. This is inspired by
4545
// this article: https://dave.cheney.net/2015/11/05/lets-talk-about-logging. However, you can create
4646
// instances of DeprecatedLogger instead, which support more levels.
4747
//
48-
// Configuration
48+
// # Configuration
4949
//
5050
// There are several package level functions which reconfigure logging output. They control which
5151
// levels are discarded, which fields are included in each log entry, and how those fields are rendered,
5252
// and how the overall log entry is rendered (JSON, LTSV, colorized, etc).
5353
//
5454
// To configure logging settings from environment variables, call the configuration function from main():
5555
//
56-
// flume.ConfigFromEnv()
56+
// flume.ConfigFromEnv()
5757
//
5858
// This reads the log configuration from the environment variable "FLUME" (the default, which can be
5959
// overridden). The value is JSON, e.g.:
6060
//
61-
// {"level":"INF","levels":"http=DBG","development"="true"}
61+
// {"level":"INF","levels":"http=DBG","development"="true"}
6262
//
6363
// The properties of the config string:
6464
//
65-
// - "level": ERR, INF, or DBG. The default level for all loggers.
66-
// - "levels": A string configuring log levels for specific loggers, overriding the default level.
67-
// See note below for syntax.
68-
// - "development": true or false. In development mode, the defaults for the other
69-
// settings change to be more suitable for developers at a terminal (colorized, multiline, human
70-
// readable, etc). See note below for exact defaults.
71-
// - "addCaller": true or false. Adds call site information to log entries (file and line).
72-
// - "encoding": json, ltsv, term, or term-color. Configures how log entries are encoded in the output.
73-
// "term" and "term-color" are multi-line, human-friendly
74-
// formats, intended for terminal output.
75-
// - "encoderConfig": a JSON object which configures advanced encoding settings, like how timestamps
76-
// are formatted. See docs for go.uber.org/zap/zapcore/EncoderConfig
77-
//
78-
// - "messageKey": the label of the message property of the log entry. If empty, message is omitted.
79-
// - "levelKey": the label of the level property of the log entry. If empty, level is omitted.
80-
// - "timeKey": the label of the timestamp of the log entry. If empty, timestamp is omitted.
81-
// - "nameKey": the label of the logger name in the log entry. If empty, logger name is omitted.
82-
// - "callerKey": the label of the logger name in the log entry. If empty, logger name is omitted.
83-
// - "lineEnding": the end of each log output line.
84-
// - "levelEncoder": capital, capitalColor, color, lower, or abbr. Controls how the log entry level
85-
// is rendered. "abbr" renders 3-letter abbreviations, like ERR and INF.
86-
// - "timeEncoder": iso8601, millis, nanos, unix, or justtime. Controls how timestamps are rendered.
87-
// "millis", "nanos", and "unix" are since UNIX epoch. "unix" is in floating point seconds.
88-
// "justtime" omits the date, and just prints the time in the format "15:04:05.000".
89-
// - "durationEncoder": string, nanos, or seconds. Controls how time.Duration values are rendered.
90-
// - "callerEncoder": full or short. Controls how the call site is rendered.
91-
// "full" includes the entire package path, "short" only includes the last folder of the package.
65+
// - "level": ERR, INF, or DBG. The default level for all loggers.
66+
//
67+
// - "levels": A string configuring log levels for specific loggers, overriding the default level.
68+
// See note below for syntax.
69+
//
70+
// - "development": true or false. In development mode, the defaults for the other
71+
// settings change to be more suitable for developers at a terminal (colorized, multiline, human
72+
// readable, etc). See note below for exact defaults.
73+
//
74+
// - "addCaller": true or false. Adds call site information to log entries (file and line).
75+
//
76+
// - "encoding": json, ltsv, term, or term-color. Configures how log entries are encoded in the output.
77+
// "term" and "term-color" are multi-line, human-friendly
78+
// formats, intended for terminal output.
79+
//
80+
// - "encoderConfig": a JSON object which configures advanced encoding settings, like how timestamps
81+
// are formatted. See docs for go.uber.org/zap/zapcore/EncoderConfig
82+
//
83+
// - "messageKey": the label of the message property of the log entry. If empty, message is omitted.
84+
//
85+
// - "levelKey": the label of the level property of the log entry. If empty, level is omitted.
86+
//
87+
// - "timeKey": the label of the timestamp of the log entry. If empty, timestamp is omitted.
88+
//
89+
// - "nameKey": the label of the logger name in the log entry. If empty, logger name is omitted.
90+
//
91+
// - "callerKey": the label of the logger name in the log entry. If empty, logger name is omitted.
92+
//
93+
// - "lineEnding": the end of each log output line.
94+
//
95+
// - "levelEncoder": capital, capitalColor, color, lower, or abbr. Controls how the log entry level
96+
// is rendered. "abbr" renders 3-letter abbreviations, like ERR and INF.
97+
//
98+
// - "timeEncoder": iso8601, millis, nanos, unix, or justtime. Controls how timestamps are rendered.
99+
// "millis", "nanos", and "unix" are since UNIX epoch. "unix" is in floating point seconds.
100+
// "justtime" omits the date, and just prints the time in the format "15:04:05.000".
101+
//
102+
// - "durationEncoder": string, nanos, or seconds. Controls how time.Duration values are rendered.
103+
//
104+
// - "callerEncoder": full or short. Controls how the call site is rendered.
105+
// "full" includes the entire package path, "short" only includes the last folder of the package.
92106
//
93107
// Defaults:
94108
//
95-
// {
96-
// "level":"INF",
97-
// "levels":"",
98-
// "development":false,
99-
// "addCaller":false,
100-
// "encoding":"term-color",
101-
// "encoderConfig":{
102-
// "messageKey":"msg",
103-
// "levelKey":"level",
104-
// "timeKey":"time",
105-
// "nameKey":"name",
106-
// "callerKey":"caller",
107-
// "lineEnding":"\n",
108-
// "levelEncoder":"abbr",
109-
// "timeEncoder":"iso8601",
110-
// "durationEncoder":"seconds",
111-
// "callerEncoder":"short",
112-
// }
113-
// }
109+
// {
110+
// "level":"INF",
111+
// "levels":"",
112+
// "development":false,
113+
// "addCaller":false,
114+
// "encoding":"term-color",
115+
// "encoderConfig":{
116+
// "messageKey":"msg",
117+
// "levelKey":"level",
118+
// "timeKey":"time",
119+
// "nameKey":"name",
120+
// "callerKey":"caller",
121+
// "lineEnding":"\n",
122+
// "levelEncoder":"abbr",
123+
// "timeEncoder":"iso8601",
124+
// "durationEncoder":"seconds",
125+
// "callerEncoder":"short",
126+
// }
127+
// }
114128
//
115129
// These defaults are only applied if one of the configuration functions is called, like ConfigFromEnv(), ConfigString(),
116130
// Configure(), or LevelsString(). Initially, all loggers are configured to discard everything, following
@@ -120,29 +134,29 @@
120134
//
121135
// Development mode: if "development"=true, the defaults for the rest of the settings change, equivalent to:
122136
//
123-
// {
124-
// "addCaller":true,
125-
// "encoding":"term-color",
126-
// "encodingConfig": {
127-
// "timeEncoder":"justtime",
128-
// "durationEncoder":"string",
129-
// }
130-
// }
137+
// {
138+
// "addCaller":true,
139+
// "encoding":"term-color",
140+
// "encodingConfig": {
141+
// "timeEncoder":"justtime",
142+
// "durationEncoder":"string",
143+
// }
144+
// }
131145
//
132146
// The "levels" value is a list of key=value pairs, configuring the level of individual named loggers.
133147
// If the key is "*", it sets the default level. If "level" and "levels" both configure the default
134148
// level, "levels" wins.
135149
// Examples:
136150
//
137-
// * // set the default level to ALL, equivalent to {"level"="ALL"}
151+
// - // set the default level to ALL, equivalent to {"level"="ALL"}
138152
// *=INF // same, but set default level to INF
139153
// *,sql=WRN // set default to ALL, set "sql" logger to WRN
140154
// *=INF,http=ALL // set default to INF, set "http" to ALL
141155
// *=INF,http // same as above. If name has no level, level is set to ALL
142156
// *=INF,-http // set default to INF, set "http" to OFF
143157
// http=INF // leave default setting unchanged.
144158
//
145-
// Factories
159+
// # Factories
146160
//
147161
// Most usages of flume will use its package functions. The package functions delegate to an internal
148162
// instance of Factory, which a the logger registry. You can create and manage your own instance of

factory.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,28 +236,28 @@ func parseConfigString(s string) map[string]interface{} {
236236
// can set the default log level, and can explicitly set the log level for individual
237237
// loggers.
238238
//
239-
// Directives
239+
// # Directives
240240
//
241241
// - Default level: Use the `*` directive to set the default log level. Examples:
242242
//
243-
// * // set the default log level to debug
244-
// -* // set the default log level to off
243+
// - // set the default log level to debug
244+
// -* // set the default log level to off
245245
//
246-
// If the `*` directive is omitted, the default log level will be set to info.
247-
// - Logger level: Use the name of the logger to set the log level for a specific
248-
// logger. Examples:
246+
// If the `*` directive is omitted, the default log level will be set to info.
249247
//
250-
// http // set the http logger to debug
251-
// -http // set the http logger to off
252-
// http=INF // set the http logger to info
248+
// - Logger level: Use the name of the logger to set the log level for a specific
249+
// logger. Examples:
253250
//
254-
// Multiple directives can be included, separated by commas. Examples:
251+
// http // set the http logger to debug
252+
// -http // set the http logger to off
253+
// http=INF // set the http logger to info
255254
//
256-
// http // set http logger to debug
257-
// http,sql // set http and sql logger to debug
258-
// *,-http,sql=INF // set the default level to debug, disable the http logger,
259-
// // and set the sql logger to info
255+
// Multiple directives can be included, separated by commas. Examples:
260256
//
257+
// http // set http logger to debug
258+
// http,sql // set http and sql logger to debug
259+
// *,-http,sql=INF // set the default level to debug, disable the http logger,
260+
// // and set the sql logger to info
261261
func (r *Factory) LevelsString(s string) error {
262262
m := parseConfigString(s)
263263
levelMap := map[string]Level{}

0 commit comments

Comments
 (0)