S&W Go Utilities
Go to file
James Hunt 76192fc2a6 New `cursor.Contains()` method
It's like a reverse Under(), except `a.Contains(a)` is true.
2017-02-15 15:44:43 -05:00
ansi ansi supports color tags split across lines. Also, better rainbows with whitespace (#5) 2016-11-12 13:10:19 -05:00
botta Updated godeps 2016-08-23 15:26:38 -04:00
log Support logging to stderr 2016-10-28 21:36:46 -04:00
timestamp adding timestamp to utils 2016-11-01 09:26:12 -04:00
tree New `cursor.Contains()` method 2017-02-15 15:44:43 -05:00
README.md Prepended SetupLogging with log 2015-11-20 13:25:58 -05:00

README.md

goutils

S&W Go Utilities

How To Use

Get:

go get github.com/starkandwayne/goutils/{{pkg}}

Import:

import "github.com/starkandwayne/goutils/{{pkg}}"

Log

Setup logging with SetupLogging():

  • Type: logging mode to use - file, syslog, console
  • Level: debug, info, error, etc. (See all levels below.)
  • Facility: syslog facility to log to - daemon, misc, etc.
  • File: path to log to file if in file mode.

e.g.:

log.SetupLogging(LogConfig{ Type: "console", Level: "warning" })

If logging is not setup, then the messages will simply go to stdout. If logging cannot be setup for file or syslog, then the default stdout will be used. An error message will print to stderr to notify you if this occurs.

Log has the following levels defined:

  • Debug
  • Info
  • Notice
  • Warn
  • Error
  • Crit
  • Alert
  • Emerg

Usage is the same as Sprintf/Printf statements - simply append an f to the desired level. e.g.:

dbug_mesg := "This isn't a bug."
log.Debugf("I really need to know this in debug mode: %s", dbug_mesg)