glogutils

package module
v0.0.0-...-11a7c75 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2013 License: Apache-2.0 Imports: 5 Imported by: 1

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupLogs

func CleanupLogs() error

Removes old logs generated by golang, should be called in some separate goroutine

func LogDir

func LogDir() string

Determines whether golang's log_dir has been set without overriding it

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL