1
0
mirror of https://github.com/taigrr/log-socket synced 2025-01-18 04:53:14 -08:00

make pass gofumpt

This commit is contained in:
Tai Groot 2022-10-14 22:23:42 -07:00
parent 2492509b6b
commit e21fb8a614
Signed by: taigrr
GPG Key ID: D00C269A87614812
4 changed files with 11 additions and 18 deletions

View File

@ -1,4 +1,4 @@
Copyright (C) 2019-2021 by Tai Groot <tai@taigrr.com>
Copyright (C) 2019-2022 by Tai Groot <tai@taigrr.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

View File

@ -26,18 +26,12 @@ func init() {
}
func (c *Client) logStdErr() {
for {
select {
case e, more := <-c.writer:
if e.level >= c.LogLevel {
fmt.Fprintf(os.Stderr, "%s\t%s\t%s\t%s\n", e.Timestamp.String(), e.Level, e.Output, e.File)
}
if !more {
stderrFinished <- true
return
}
for e := range c.writer {
if e.level >= c.LogLevel {
fmt.Fprintf(os.Stderr, "%s\t%s\t%s\t%s\n", e.Timestamp.String(), e.Level, e.Output, e.File)
}
}
stderrFinished <- true
}
func CreateClient() *Client {
@ -61,7 +55,7 @@ func Flush() {
func (c *Client) Destroy() error {
var otherClients []*Client
if !c.initialized {
panic(errors.New("Cannot delete uninitialized client, did you use CreateClient?"))
panic(errors.New("cannot delete uninitialized client, did you use CreateClient?"))
}
sliceTex.Lock()
c.writer = nil
@ -78,7 +72,7 @@ func (c *Client) Destroy() error {
func (c *Client) GetLogLevel() Level {
if !c.initialized {
panic(errors.New("Cannot get level for uninitialized client, use CreateClient instead"))
panic(errors.New("cannot get level for uninitialized client, use CreateClient instead"))
}
return c.LogLevel
}
@ -109,14 +103,14 @@ func SetLogLevel(level Level) {
// SetLogLevel set log level of logger
func (c *Client) SetLogLevel(level Level) {
if !c.initialized {
panic(errors.New("Cannot set level for uninitialized client, use CreateClient instead"))
panic(errors.New("cannot set level for uninitialized client, use CreateClient instead"))
}
c.LogLevel = level
}
func (c *Client) Get() Entry {
if !c.initialized {
panic(errors.New("Cannot get logs for uninitialized client, did you use CreateClient?"))
panic(errors.New("cannot get logs for uninitialized client, did you use CreateClient?"))
}
return <-c.writer
}

View File

@ -55,8 +55,7 @@ func BenchmarkDebugSerial(b *testing.B) {
// Trace ensure logs come out in the right order
func TestOrder(t *testing.T) {
testString := "Testing trace: "
var c *Client
c = CreateClient()
c := CreateClient()
c.SetLogLevel(LTrace)
for i := 0; i < 5000; i++ {

View File

@ -25,7 +25,7 @@ func LogSocketHandler(w http.ResponseWriter, r *http.Request) {
logger.Info("Websocket client attached.")
for {
logEvent := lc.Get()
logJSON, err := json.Marshal(logEvent)
logJSON, _ := json.Marshal(logEvent)
err = c.WriteMessage(websocket.TextMessage, logJSON)
if err != nil {
logger.Error("write:", err)