@@ -117,7 +117,7 @@ func formatCall(format string, c stack.Call) string {
117
117
}
118
118
119
119
// CallerStackHandler returns a Handler that adds a stack trace to the context
120
- // with key "stack". The stack trace is formated as a space separated list of
120
+ // with key "stack". The stack trace is formatted as a space separated list of
121
121
// call sites inside matching []'s. The most recent call site is listed first.
122
122
// Each call site is formatted according to format. See the documentation of
123
123
// package github.com/go-stack/stack for the list of supported formats.
@@ -135,15 +135,14 @@ func CallerStackHandler(format string, h Handler) Handler {
135
135
// wrapped Handler if the given function evaluates true. For example,
136
136
// to only log records where the 'err' key is not nil:
137
137
//
138
- // logger.SetHandler(FilterHandler(func(r *Record) bool {
139
- // for i := 0; i < len(r.Ctx); i += 2 {
140
- // if r.Ctx[i] == "err" {
141
- // return r.Ctx[i+1] != nil
142
- // }
143
- // }
144
- // return false
145
- // }, h))
146
- //
138
+ // logger.SetHandler(FilterHandler(func(r *Record) bool {
139
+ // for i := 0; i < len(r.Ctx); i += 2 {
140
+ // if r.Ctx[i] == "err" {
141
+ // return r.Ctx[i+1] != nil
142
+ // }
143
+ // }
144
+ // return false
145
+ // }, h))
147
146
func FilterHandler (fn func (r * Record ) bool , h Handler ) Handler {
148
147
return FuncHandler (func (r * Record ) error {
149
148
if fn (r ) {
@@ -158,8 +157,7 @@ func FilterHandler(fn func(r *Record) bool, h Handler) Handler {
158
157
// context matches the value. For example, to only log records
159
158
// from your ui package:
160
159
//
161
- // log.MatchFilterHandler("pkg", "app/ui", log.StdoutHandler)
162
- //
160
+ // log.MatchFilterHandler("pkg", "app/ui", log.StdoutHandler)
163
161
func MatchFilterHandler (key string , value interface {}, h Handler ) Handler {
164
162
return FilterHandler (func (r * Record ) (pass bool ) {
165
163
switch key {
@@ -185,8 +183,7 @@ func MatchFilterHandler(key string, value interface{}, h Handler) Handler {
185
183
// level to the wrapped Handler. For example, to only
186
184
// log Error/Crit records:
187
185
//
188
- // log.LvlFilterHandler(log.LvlError, log.StdoutHandler)
189
- //
186
+ // log.LvlFilterHandler(log.LvlError, log.StdoutHandler)
190
187
func LvlFilterHandler (maxLvl Lvl , h Handler ) Handler {
191
188
return FilterHandler (func (r * Record ) (pass bool ) {
192
189
return r .Lvl <= maxLvl
@@ -198,10 +195,9 @@ func LvlFilterHandler(maxLvl Lvl, h Handler) Handler {
198
195
// to different locations. For example, to log to a file and
199
196
// standard error:
200
197
//
201
- // log.MultiHandler(
202
- // log.Must.FileHandler("/var/log/app.log", log.LogfmtFormat()),
203
- // log.StderrHandler)
204
- //
198
+ // log.MultiHandler(
199
+ // log.Must.FileHandler("/var/log/app.log", log.LogfmtFormat()),
200
+ // log.StderrHandler)
205
201
func MultiHandler (hs ... Handler ) Handler {
206
202
return FuncHandler (func (r * Record ) error {
207
203
for _ , h := range hs {
@@ -219,10 +215,10 @@ func MultiHandler(hs ...Handler) Handler {
219
215
// to writing to a file if the network fails, and then to
220
216
// standard out if the file write fails:
221
217
//
222
- // log.FailoverHandler(
223
- // log.Must.NetHandler("tcp", ":9090", log.JsonFormat()),
224
- // log.Must.FileHandler("/var/log/app.log", log.LogfmtFormat()),
225
- // log.StdoutHandler)
218
+ // log.FailoverHandler(
219
+ // log.Must.NetHandler("tcp", ":9090", log.JsonFormat()),
220
+ // log.Must.FileHandler("/var/log/app.log", log.LogfmtFormat()),
221
+ // log.StdoutHandler)
226
222
//
227
223
// All writes that do not go to the first handler will add context with keys of
228
224
// the form "failover_err_{idx}" which explain the error encountered while
0 commit comments