Sphire Mantis API Documentation

Sphire Mantis' API Documentation

View the Project on GitHub sphireinc/Mantis

Go Report Card Go Reference

log

import "github.com/sphireinc/mantis/log"

Index

Constants

INFO, WARN, ERROR, FATAL, PANIC are the package level Log Levels

const (
    INFO = iota
    WARN
    ERROR
    FATAL
    PANIC
)

func JSONMarshalError

func JSONMarshalError(err error) string

JSONMarshalError takes an error and JSON Marshals it

func expand

func expand(additional []string) string

expand our string slice into a string separated by <>

type Log

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

func New(filename string, printToTerm bool, overwrite bool) (*Log, error)

New creates a new Log instance given filename

func (*Log) Error

func (l *Log) Error(msg string, additional ...string)

Error writes an error level log message

func (*Log) Fatal

func (l *Log) Fatal(msg string, additional ...string)

Fatal writes a fatal level log message, then os.Exits

func (*Log) HandleError

func (l *Log) HandleError(message string, err error)

HandleError handles an error with an error message.

func (*Log) HandleFatalError

func (l *Log) HandleFatalError(err error)

HandleFatalError is (nicer) wrapper to panic.

func (*Log) Info

func (l *Log) Info(msg string, additional ...string)

Info writes an info level log message

func (*Log) JSONMarshalAndLogError

func (l *Log) JSONMarshalAndLogError(message string, err error) string

JSONMarshalAndLogError logs and error then JSON Marshals it

func (*Log) LogHTTPRequest

func (l *Log) LogHTTPRequest(name string, w http.ResponseWriter, r *http.Request)

LogHTTPRequest logs an HTTP request from writer with a given name

func (*Log) Panic

func (l *Log) Panic(msg string, additional ...string)

Panic writes a panic level log message then panics

func (*Log) SetLogLevel

func (l *Log) SetLogLevel(level int)

SetLogLevel allows the log level to be set using package consts

func (*Log) String

func (l *Log) String() string

String converts our Log struct into a JSON string

func (*Log) Warn

func (l *Log) Warn(msg string, additional ...string)

Warn writes a warning level log message

func (*Log) Write

func (l *Log) Write(msg ...string)

Write a message to log and prepend time

func (*Log) writer

func (l *Log) writer(logLevel int, msg string)

writer a message to log and prepend time

Generated by gomarkdoc