Skip to content

A set of simple logging utilities written in go that are easily configurable and geared towards simple use cases.

License

Notifications You must be signed in to change notification settings

kogosoftwarellc/go-simple-logging

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-simple-logging

A set of simple logging utilities written in go that are easily configurable and geared towards simple use cases.

Example

	logger := logging.NewLogger()
	logging.LogLevel = logging.LOG_LEVEL_DEBUG
	logging.Debug("foo")
	logging.Debugf("debug: %s", "foo")
	logging.Error(1)
	logging.Errorf("error: %d", 1)
	logging.Info("hello")
	logging.Infof("info: %s", "hello")
	logging.Warn(true)
	logging.Warnf("warn: %t", true)

Changing log destination

Logger has the following properties. You can assign any os.File to redirect log output to that location.

  • DebugFile (defaults to os.Stderr)
  • ErrorFile (defaults to os.Stderr)
  • InfoFile (defaults to os.Stdout)
  • WarnFile (defaults to os.Stderr)

Changing the log level

Logger has the LogLevel property which is an int. The following convenient constants are exported:

  • LOG_LEVEL_NONE turns off all logging.
  • LOG_LEVEL_ERROR allows Error logs.
  • LOG_LEVEL_WARN allows Error and Warn logs.
  • LOG_LEVEL_INFO allows Error, Warn, and Info logs.
  • LOG_LEVEL_DEBUG allows Error, Warn, Info, and Debug logs.

About

A set of simple logging utilities written in go that are easily configurable and geared towards simple use cases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%