Sphire Mantis' API Documentation
import "github.com/sphireinc/mantis/log"
INFO, WARN, ERROR, FATAL, PANIC are the package level Log Levels
const (
INFO = iota
WARN
ERROR
FATAL
PANIC
)
func JSONMarshalError(err error) string
JSONMarshalError takes an error and JSON Marshals it
func expand(additional []string) string
expand our string slice into a string separated by <>
Log is our primary log struct
type Log struct {
Logger *log.Logger `json:"logger,omitempty"`
Filename string `json:"filename,omitempty"`
Status bool `json:"status,omitempty"`
PrintToTerm bool `json:"print_to_term,omitempty"`
Overwrite bool `json:"overwrite,omitempty"`
MinLogLevel int `json:"min_log_level,omitempty"`
WriteSeparator string `json:"write_separator,omitempty"`
}
func New(filename string, printToTerm bool, overwrite bool) (*Log, error)
New creates a new Log instance given filename
func (l *Log) Error(msg string, additional ...string)
Error writes an error level log message
func (l *Log) Fatal(msg string, additional ...string)
Fatal writes a fatal level log message, then os.Exits
func (l *Log) HandleError(message string, err error)
HandleError handles an error with an error message.
func (l *Log) HandleFatalError(err error)
HandleFatalError is (nicer) wrapper to panic.
func (l *Log) Info(msg string, additional ...string)
Info writes an info level log message
func (l *Log) JSONMarshalAndLogError(message string, err error) string
JSONMarshalAndLogError logs and error then JSON Marshals it
func (l *Log) LogHTTPRequest(name string, w http.ResponseWriter, r *http.Request)
LogHTTPRequest logs an HTTP request from writer with a given name
func (l *Log) Panic(msg string, additional ...string)
Panic writes a panic level log message then panics
func (l *Log) SetLogLevel(level int)
SetLogLevel allows the log level to be set using package consts
func (l *Log) String() string
String converts our Log struct into a JSON string
func (l *Log) Warn(msg string, additional ...string)
Warn writes a warning level log message
func (l *Log) Write(msg ...string)
Write a message to log and prepend time
func (l *Log) writer(logLevel int, msg string)
writer a message to log and prepend time
Generated by gomarkdoc