Skip to content
/ glogutils Public
forked from mailgun/glogutils

Utils for working with google logging library

License

Notifications You must be signed in to change notification settings

7ing/glogutils

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Rationale

Google logging library is a wonderful lib:

https://github.com/golang/glog

However the logs that it generates are never deleted.

glogutils adds one function to cleanup logs:

glogutils.CleanupLogs() //Deletes files that are no longer active

and another one to understand if google logging logs to dir:

glogutils.LogDir() // returns "" if log dir was not specified

Example

// This function starts cleaning up after glog library, periodically removing logs
// that are no longer used
func startLogsCleanup(period time.Duration) error {
	if glogutils.LogDir() != "" {
		glog.Infof("Starting log cleanup go routine with period: %s", period)
		go func() {
			t := time.Tick(period)
			for {
				select {
				case <-t:
					glog.Infof("Start cleaning up the logs")
					err := glogutils.CleanupLogs()
					if err != nil {
						glog.Errorf("Failed to clean up the logs: %s", err)
						return
					}
				}
			}
		}()
	}
	return nil
}

License

Apache2

About

Utils for working with google logging library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 96.9%
  • Makefile 3.1%