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:
22
log/log.go
22
log/log.go
@@ -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
|
||||
}
|
||||
|
||||
@@ -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++ {
|
||||
|
||||
Reference in New Issue
Block a user