File tree Expand file tree Collapse file tree 6 files changed +31
-5
lines changed Expand file tree Collapse file tree 6 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 11## log
22<img align =" right " src =" https://raw.githubusercontent.com/go-playground/log/master/logo.png " >
3- ![ Project status] ( https://img.shields.io/badge/version-4.0.0 -green.svg )
3+ ![ Project status] ( https://img.shields.io/badge/version-4.0.1 -green.svg )
44[ ![ Build Status] ( https://semaphoreci.com/api/v1/joeybloggs/log/branches/master/badge.svg )] ( https://semaphoreci.com/joeybloggs/log )
55[ ![ Coverage Status] ( https://coveralls.io/repos/github/go-playground/log/badge.svg?branch=master )] ( https://coveralls.io/github/go-playground/log?branch=master )
66[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/go-playground/log )] ( https://goreportcard.com/report/github.com/go-playground/log )
Original file line number Diff line number Diff line change 77 stdlog "log"
88 "os"
99 "strconv"
10+ "strings"
1011
1112 "github.com/go-playground/log"
1213)
@@ -358,7 +359,12 @@ func defaultFormatFunc(c *Console) Formatter {
358359 }
359360 }
360361 } else {
361- file = file [len (gopath ):]
362+
363+ // additional check, just in case user does
364+ // have a $GOPATH but code isnt under it.
365+ if strings .HasPrefix (file , gopath ) {
366+ file = file [len (gopath ):]
367+ }
362368 }
363369
364370 b = append (b , e .Timestamp .Format (tsFormat )... )
Original file line number Diff line number Diff line change 55 "html/template"
66 stdlog "log"
77 "os"
8+ "strings"
89 "sync"
910 "time"
1011
@@ -171,7 +172,12 @@ func (email *Email) Run() chan<- *log.Entry {
171172 }
172173 }
173174 } else {
174- file = file [len (email .gopath ):]
175+
176+ // additional check, just in case user does
177+ // have a $GOPATH but code isnt under it.
178+ if strings .HasPrefix (file , email .gopath ) {
179+ file = file [len (email .gopath ):]
180+ }
175181 }
176182
177183 return
Original file line number Diff line number Diff line change @@ -209,7 +209,12 @@ func (hc *HipChat) Run() chan<- *log.Entry {
209209 }
210210 }
211211 } else {
212- file = file [len (hc .GOPATH ()):]
212+
213+ // additional check, just in case user does
214+ // have a $GOPATH but code isnt under it.
215+ if strings .HasPrefix (file , hc .GOPATH ()) {
216+ file = file [len (hc .GOPATH ()):]
217+ }
213218 }
214219
215220 return
Original file line number Diff line number Diff line change 99 "net/url"
1010 "os"
1111 "strconv"
12+ "strings"
1213
1314 "github.com/go-playground/log"
1415)
@@ -221,7 +222,12 @@ func defaultFormatFunc(h HTTP) Formatter {
221222 }
222223 }
223224 } else {
224- file = file [len (gopath ):]
225+
226+ // additional check, just in case user does
227+ // have a $GOPATH but code isnt under it.
228+ if strings .HasPrefix (file , gopath ) {
229+ file = file [len (gopath ):]
230+ }
225231 }
226232
227233 b = append (b , e .Timestamp .Format (tsFormat )... )
Original file line number Diff line number Diff line change @@ -350,6 +350,9 @@ func defaultFormatFunc(s *Syslog) Formatter {
350350 }
351351 }
352352 } else {
353+
354+ // additional check, just in case user does
355+ // have a $GOPATH but code isnt under it.
353356 if strings .HasPrefix (file , gopath ) {
354357 file = file [len (gopath ):]
355358 }
You can’t perform that action at this time.
0 commit comments