Skip to content

Commit 0fd1c3f

Browse files
committed
code optimize and cleanup
1 parent 52a527f commit 0fd1c3f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

console_receiver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type ConsoleReceiver struct {
4040
flags []ess.FmtFlagPart
4141
isCallerInfo bool
4242
isColor bool
43-
mu *sync.Mutex
43+
mu sync.Mutex
4444
}
4545

4646
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
@@ -61,7 +61,7 @@ func (c *ConsoleReceiver) Init(cfg *config.Config) error {
6161
return fmt.Errorf("log: unsupported format '%s'", c.formatter)
6262
}
6363

64-
c.mu = &sync.Mutex{}
64+
c.mu = sync.Mutex{}
6565

6666
return nil
6767
}

entry.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ type Fields map[string]interface{}
2626
// Entry represents a log entry and contains the timestamp when the entry
2727
// was created, level, etc.
2828
type Entry struct {
29+
Level level `json:"-"`
30+
Line int `json:"line,omitempty"`
2931
AppName string `json:"app_name,omitempty"`
3032
InstanceName string `json:"instance_name,omitempty"`
3133
RequestID string `json:"request_id,omitempty"`
3234
Principal string `json:"principal,omitempty"`
33-
Level level `json:"-"`
34-
Time time.Time `json:"-"`
3535
Message string `json:"message,omitempty"`
3636
File string `json:"file,omitempty"`
37-
Line int `json:"line,omitempty"`
3837
Fields Fields `json:"fields,omitempty"`
39-
40-
logger *Logger
38+
Time time.Time `json:"-"`
39+
logger *Logger
4140
}
4241

4342
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
@@ -47,7 +46,7 @@ type Entry struct {
4746
// MarshalJSON method for formating entry to JSON.
4847
func (e *Entry) MarshalJSON() ([]byte, error) {
4948
type alias Entry
50-
ne := &struct {
49+
ne := struct {
5150
Level string `json:"level,omitempty"`
5251
Time string `json:"timestamp,omitempty"`
5352
*alias

file_receiver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type FileReceiver struct {
3434
flags []ess.FmtFlagPart
3535
isCallerInfo bool
3636
stats *receiverStats
37-
mu *sync.Mutex
37+
mu sync.Mutex
3838
isClosed bool
3939
rotatePolicy string
4040
openDay int
@@ -85,7 +85,7 @@ func (f *FileReceiver) Init(cfg *config.Config) error {
8585
f.maxSize = maxSize
8686
}
8787

88-
f.mu = &sync.Mutex{}
88+
f.mu = sync.Mutex{}
8989

9090
return nil
9191
}

0 commit comments

Comments
 (0)