Skip to content

Lock Free glg Release

Compare
Choose a tag to compare
@kpango kpango released this 25 May 03:14
· 175 commits to master since this release

This release contains 4 changes

1. Remove mutex lock from internal implementation of glg and changed to lock free algorithm.

2. glg used string as the search key for log level map but changed to uint8 for performance improvement.

 - type LEVEL uint8
 - map[LEVEL]*logger

3. In order to improve the performance at multiple goroutine, instead of calling the time with all goroutine, we made it a daemon and called it in a single place and let all goroutines refer to that place.

 - func (g *Glg) startTimerD() *Glg start glg timer daemon The glg instance calls it automatically

4. Adding multiple new methods.

 - func (g *Glg) Stop() *Glg Stop glg timer daemon
 - func (g *Glg) EnableLevelColor(lv LEVEL) *Glg We've set color on / off all together, but now you can turn on colors for each log level
 - func (g *Glg) DisableLevelColor(lv LEVEL) *Glg We've set color on / off all together, but now you can turn off colors for each log level
 - func (g *Glg) TagStringToLevel(tag string) LEVEL Convert from a custom level string that users can freely add to LEVEL used inside glg

attention

according to the search key of map is set to uint8, the setting method has been changed only in the case of the custom log level.
To set a custom level with SetLevel ~~~ method, specify Level using TagStringToLevel.

customTag := "FINE"
glg.Get().
       AddStdLevel(customTag, glg.STD, false).
       SetLevelColor(glg.TagStringToLevel(customTag), glg.Cyan)

If you need more information, see example