...

Package log

import "github.com/Diarkis/diarkis/log"
Overview
Index
Subdirectories

Overview ▾

Package log ▷

Log

Diarkis logger.

Log Configurations

Log configurations are explained below.

{
  "level": "verbose",
  "timeZone": "local",
  "color": true,
  "flat": false,
  "filePath": "path/to/log/file"
}

Configuration Values

level - Default is "verbose"

Controls logger level: verbose < sys < debug(trace) < info < notice < warn < error < fatal.

timeZone - Default is "utc"

Valid configuration value are "utc" or "local". Default is UTC.

color - Default is true

if false, the output log has no color. The default is true.

flat - Default is false

if true, the output log has no line breaks. The default is false.

filePath - Default is ""

File path to output log data to (absolute path).

Environment variable: DIARKIS_STACKDRIVER_LOG=true

This converts all output log into StackDriver formatted JSON log.

Index ▾

func CloseFileOutput(next func(error))
func FmtBlue(msg string) string
func FmtDBlue(msg string) string
func FmtGreen(msg string) string
func FmtGrey(msg string) string
func FmtLBlue(msg string) string
func FmtPurple(msg string) string
func FmtRed(msg string) string
func FmtRedBg(msg string) string
func FmtYellow(msg string) string
func IsDebug() bool
func IsError() bool
func IsFatal() bool
func IsInfo() bool
func IsNotice() bool
func IsSys() bool
func IsVerbose() bool
func IsWarn() bool
func Level(_level int)
func SetCustomOutput(custom func(string, string, string, []interface{}) string)
func SetPrefix(prefix string)
func Setup(confpath string)
func UpdateConfigs(configs map[string]interface{})
func UseCustomOutput()
func UseStackdriverLogging()
type Logger
    func New(name string) *Logger
    func (logger *Logger) Debug(vals ...interface{})
    func (logger *Logger) DisableCustom()
    func (logger *Logger) EnableCustom()
    func (logger *Logger) Error(vals ...interface{})
    func (logger *Logger) Fatal(vals ...interface{})
    func (logger *Logger) FmtDebug(vals ...interface{}) string
    func (logger *Logger) FmtError(vals ...interface{}) string
    func (logger *Logger) FmtFatal(vals ...interface{}) string
    func (logger *Logger) FmtInfo(vals ...interface{}) string
    func (logger *Logger) FmtNotice(vals ...interface{}) string
    func (logger *Logger) FmtSys(vals ...interface{}) string
    func (logger *Logger) FmtVerbose(vals ...interface{}) string
    func (logger *Logger) FmtWarn(vals ...interface{}) string
    func (logger *Logger) Info(vals ...interface{})
    func (logger *Logger) Notice(vals ...interface{})
    func (logger *Logger) Sys(vals ...interface{})
    func (logger *Logger) Trace(vals ...interface{})
    func (logger *Logger) Verbose(vals ...interface{})
    func (logger *Logger) Warn(vals ...interface{})
    func (logger *Logger) Write(vals ...interface{})

func CloseFileOutput

func CloseFileOutput(next func(error))

CloseFileOutput [INTERNAL USE ONLY] Closes the file descriptor of log data if used

func FmtBlue

func FmtBlue(msg string) string

FmtBlue Colorize the given string

func FmtDBlue

func FmtDBlue(msg string) string

FmtDBlue Colorize the given string

func FmtGreen

func FmtGreen(msg string) string

FmtGreen Colorize the given string

func FmtGrey

func FmtGrey(msg string) string

FmtGrey Colorize the given string

func FmtLBlue

func FmtLBlue(msg string) string

FmtLBlue Colorize the given string

func FmtPurple

func FmtPurple(msg string) string

FmtPurple Colorize the given string

func FmtRed

func FmtRed(msg string) string

FmtRed Colorize the given string

func FmtRedBg

func FmtRedBg(msg string) string

FmtRedBg Colorize the given string

func FmtYellow

func FmtYellow(msg string) string

FmtYellow Colorize the given string

func IsDebug

func IsDebug() bool

IsDebug returns true if the log level is debug

func IsError

func IsError() bool

IsError returns true if the log level is error

func IsFatal

func IsFatal() bool

IsFatal returns true if the log level is fatal

func IsInfo

func IsInfo() bool

IsInfo returns true if the log level is info

func IsNotice

func IsNotice() bool

IsNotice returns true if the log level is notice

func IsSys

func IsSys() bool

IsSys returns true if the log level is sys

func IsVerbose

func IsVerbose() bool

IsVerbose returns true if the log level is verbose

func IsWarn

func IsWarn() bool

IsWarn returns true if the log level is warn

func Level

func Level(_level int)

Level Sets logging level

func SetCustomOutput

func SetCustomOutput(custom func(string, string, string, []interface{}) string)

SetCustomOutput Registers a custom function to create a log output string

func SetPrefix

func SetPrefix(prefix string)

SetPrefix Sets a prefix for every log

func Setup

func Setup(confpath string)

Setup Load a configuration file into memory - pass an empty string to load nothing

func UpdateConfigs

func UpdateConfigs(configs map[string]interface{})

UpdateConfigs Apply configurations It can be executed in runtime to update the configurations also

func UseCustomOutput

func UseCustomOutput()

UseCustomOutput Enables custom output You must first set a custom log output function using SetCustomOutput()

func UseStackdriverLogging

func UseStackdriverLogging()

UseStackdriverLogging converts the logging format to stackdriver log entry format

type Logger

Logger Logger data structure

type Logger struct {
    Name string
    // contains filtered or unexported fields
}

func New

func New(name string) *Logger

New Creates a new logger

func (*Logger) Debug

func (logger *Logger) Debug(vals ...interface{})

Debug Outputs a log to stdout stream

func (*Logger) DisableCustom

func (logger *Logger) DisableCustom()

DisableCustom blocks logger.Write()

func (*Logger) EnableCustom

func (logger *Logger) EnableCustom()

EnableCustom allows logger.Write()

func (*Logger) Error

func (logger *Logger) Error(vals ...interface{})

Error Outputs a log to stdout stream

func (*Logger) Fatal

func (logger *Logger) Fatal(vals ...interface{})

Fatal Outputs a log to stdout stream

func (*Logger) FmtDebug

func (logger *Logger) FmtDebug(vals ...interface{}) string

FmtDebug Formats given strings and returns it for logging purpose

func (*Logger) FmtError

func (logger *Logger) FmtError(vals ...interface{}) string

FmtError Formats given strings and returns it for logging purpose

func (*Logger) FmtFatal

func (logger *Logger) FmtFatal(vals ...interface{}) string

FmtFatal Formats given strings and returns it for logging purpose

func (*Logger) FmtInfo

func (logger *Logger) FmtInfo(vals ...interface{}) string

FmtInfo Formats given strings and returns it for logging purpose

func (*Logger) FmtNotice

func (logger *Logger) FmtNotice(vals ...interface{}) string

FmtNotice Formats given strings and returns it for logging purpose

func (*Logger) FmtSys

func (logger *Logger) FmtSys(vals ...interface{}) string

FmtSys Formats given strings and returns it for logging purpose

func (*Logger) FmtVerbose

func (logger *Logger) FmtVerbose(vals ...interface{}) string

FmtVerbose Formats given strings and returns it for logging purpose

func (*Logger) FmtWarn

func (logger *Logger) FmtWarn(vals ...interface{}) string

FmtWarn Formats given strings and returns it for logging purpose

func (*Logger) Info

func (logger *Logger) Info(vals ...interface{})

Info Outputs a log to stdout stream

func (*Logger) Notice

func (logger *Logger) Notice(vals ...interface{})

Notice Outputs a log to stdout stream

func (*Logger) Sys

func (logger *Logger) Sys(vals ...interface{})

Sys Outputs a log to stdout stream

func (*Logger) Trace

func (logger *Logger) Trace(vals ...interface{})

Trace Outputs a log to stdout stream as Sys level log with stack trace. Useful for debugging

func (*Logger) Verbose

func (logger *Logger) Verbose(vals ...interface{})

Verbose Outputs a log to stdout stream

func (*Logger) Warn

func (logger *Logger) Warn(vals ...interface{})

Warn Outputs a log to stdout stream

func (*Logger) Write

func (logger *Logger) Write(vals ...interface{})

Write outputs a log to stdout stream

Subdirectories

Name Synopsis
..
lib
colorize
msg
std