Skip to content

Commit e21fb8a

Browse files
committed
make pass gofumpt
1 parent 2492509 commit e21fb8a

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2019-2021 by Tai Groot <[email protected]>
1+
Copyright (C) 2019-2022 by Tai Groot <[email protected]>
22

33
Permission to use, copy, modify, and/or distribute this software for any
44
purpose with or without fee is hereby granted.

log/log.go

+8-14
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,12 @@ func init() {
2626
}
2727

2828
func (c *Client) logStdErr() {
29-
for {
30-
select {
31-
case e, more := <-c.writer:
32-
if e.level >= c.LogLevel {
33-
fmt.Fprintf(os.Stderr, "%s\t%s\t%s\t%s\n", e.Timestamp.String(), e.Level, e.Output, e.File)
34-
}
35-
if !more {
36-
stderrFinished <- true
37-
return
38-
}
29+
for e := range c.writer {
30+
if e.level >= c.LogLevel {
31+
fmt.Fprintf(os.Stderr, "%s\t%s\t%s\t%s\n", e.Timestamp.String(), e.Level, e.Output, e.File)
3932
}
4033
}
34+
stderrFinished <- true
4135
}
4236

4337
func CreateClient() *Client {
@@ -61,7 +55,7 @@ func Flush() {
6155
func (c *Client) Destroy() error {
6256
var otherClients []*Client
6357
if !c.initialized {
64-
panic(errors.New("Cannot delete uninitialized client, did you use CreateClient?"))
58+
panic(errors.New("cannot delete uninitialized client, did you use CreateClient?"))
6559
}
6660
sliceTex.Lock()
6761
c.writer = nil
@@ -78,7 +72,7 @@ func (c *Client) Destroy() error {
7872

7973
func (c *Client) GetLogLevel() Level {
8074
if !c.initialized {
81-
panic(errors.New("Cannot get level for uninitialized client, use CreateClient instead"))
75+
panic(errors.New("cannot get level for uninitialized client, use CreateClient instead"))
8276
}
8377
return c.LogLevel
8478
}
@@ -109,14 +103,14 @@ func SetLogLevel(level Level) {
109103
// SetLogLevel set log level of logger
110104
func (c *Client) SetLogLevel(level Level) {
111105
if !c.initialized {
112-
panic(errors.New("Cannot set level for uninitialized client, use CreateClient instead"))
106+
panic(errors.New("cannot set level for uninitialized client, use CreateClient instead"))
113107
}
114108
c.LogLevel = level
115109
}
116110

117111
func (c *Client) Get() Entry {
118112
if !c.initialized {
119-
panic(errors.New("Cannot get logs for uninitialized client, did you use CreateClient?"))
113+
panic(errors.New("cannot get logs for uninitialized client, did you use CreateClient?"))
120114
}
121115
return <-c.writer
122116
}

log/log_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ func BenchmarkDebugSerial(b *testing.B) {
5555
// Trace ensure logs come out in the right order
5656
func TestOrder(t *testing.T) {
5757
testString := "Testing trace: "
58-
var c *Client
59-
c = CreateClient()
58+
c := CreateClient()
6059
c.SetLogLevel(LTrace)
6160

6261
for i := 0; i < 5000; i++ {

ws/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func LogSocketHandler(w http.ResponseWriter, r *http.Request) {
2525
logger.Info("Websocket client attached.")
2626
for {
2727
logEvent := lc.Get()
28-
logJSON, err := json.Marshal(logEvent)
28+
logJSON, _ := json.Marshal(logEvent)
2929
err = c.WriteMessage(websocket.TextMessage, logJSON)
3030
if err != nil {
3131
logger.Error("write:", err)

0 commit comments

Comments
 (0)