audit

package module
v0.0.0-...-ddbd82c Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

README

go-audit - Error Handling, Logging and Instrumentation for Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(err error)

Assert checks if err is nil or not, if not, it panics with that err.

func Dbg

func Dbg(prefix, msg string, args ...interface{})

Dbg output message if current function is targeted for debugging. prefix is added to every single line of log output for tracing purpose.

func Error

func Error(prefix, msg string, args ...interface{})

Error output message with stack trace. prefix is added to every single

func ExpLogs

func ExpLogs()

func ExpVars

func ExpVars(vars map[string]interface{})

ExpVars export configuration information to /debug/vars. It will by default export the following variables:

  • epoch: start time of the current instance
  • pid: process ID of current instance
  • debugging: debug targets
  • logging: logging configuration and runtime stats

This function should be called at program start-up.

func FlushLogs

func FlushLogs(timeout int)

FlushLogs ensures log messages are flushed on program termination

func GetDebugging

func GetDebugging() bool

GetDebugging get debugging switch status

func Jsonify

func Jsonify(value interface{}, indent ...string) string

func Log

func Log(prefix, msg string, args ...interface{})

Log output message. prefix is added to every single line of log output for tracing purpose.

func RunDebugServer

func RunDebugServer(host, port string) error

RunDebugServer run a standalone http server to server debugging end points (/debug/vars, /debug/pprof etc). It is only needed if the program is not already running an http server. Unlike StartDebugServer, this function should only be called as last statement of the main function.

func SetDebugging

func SetDebugging(onoff bool)

SetDebugging turn debugging on or off.

func SetLogBuffer

func SetLogBuffer(size int) error

SetLogBuffer sets the size of log buffer. If logging is so frequent as to fill the buffer before flushing happens every 1 or 2 seconds, new messages will be dropped. Dropping of log messages can be monitored by /debug/vars if exposed.

func SetLogFile

func SetLogFile(filePath string) error

SetLogFile specifies desination for logs. If filePath is set to empty, logging will be effectively disabled.

func SetLogFilter

func SetLogFilter(filter LogFilter)

SetLogFilter sets log filter.

func SetLogRotate

func SetLogRotate(size, keep int) error

SetLogRotate sets size of single log file, and the number of log files to keep.

func StartDebugServer

func StartDebugServer(host, port string)

StartDebugServer calls RunDebugServer from a goroutine.

Types

type Exception

type Exception []string

Exception error with stack trace

func Trace

func Trace(msg string, args ...interface{}) (logs Exception)

Trace returns the current stack trace

func (Exception) Error

func (e Exception) Error() string

type LogFilter

type LogFilter func([]string) []string

LogFilter is called when a message is being sent to the buffer. If it returns nil, the message will be dropped. This callback function is useful for augmenting messages or to implement alternative log destinations.

Jump to

Keyboard shortcuts

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