log: github.com/nuveo/log Index | Files | Directories

package log

import "github.com/nuveo/log"

Index

Package Files

log.go

Constants

const (
    MessageLog         MsgType = 0
    Message2Log        MsgType = 1
    WarningLog         MsgType = 2
    DebugLog           MsgType = 3
    ErrorLog           MsgType = 4
    FormattedOut       OutType = 0
    LineOut            OutType = 1
    DefaultMaxLineSize int     = 2000
    DefaultTimeFormat  string  = "2006/01/02 15:04:05"
)

Variables

var (
    // DebugMode Enable debug mode
    DebugMode bool

    // EnableANSIColors enables ANSI colors, default true
    EnableANSIColors = true

    // MaxLineSize limits the size of the line, if the size
    // exceeds that indicated by MaxLineSize the system cuts
    // the string and adds "..." at the end.
    MaxLineSize = DefaultMaxLineSize

    // TimeFormat defines which pattern will be applied for
    // display time in the logs.
    TimeFormat = DefaultTimeFormat

    // Colors contain color array
    Colors = []string{
        MessageLog:  "\x1b[37m",
        Message2Log: "\x1b[92m",
        WarningLog:  "\x1b[93m",
        DebugLog:    "\x1b[96m",
        ErrorLog:    "\x1b[91m",
    }

    // Prefixes of messages
    Prefixes = []string{
        MessageLog:  "msg",
        Message2Log: "msg",
        WarningLog:  "warning",
        DebugLog:    "debug",
        ErrorLog:    "error",
    }
)

func AddAdapter Uses

func AddAdapter(name string, adapter AdapterPod)

AddAdapter allows to add an adapter and parameters

func Debugf Uses

func Debugf(msg ...interface{})

Debugf shows debug message on stdout without line break at the end. If debug mode is not active no message is displayed

func Debugln Uses

func Debugln(msg ...interface{})

Debugln shows debug message on stdout with line break at the end. If debug mode is not active no message is displayed

func DefaultAdapter Uses

func DefaultAdapter(m MsgType, o OutType, config map[string]interface{}, msg ...interface{})

DefaultAdapter of log package

func Errorf Uses

func Errorf(msg ...interface{})

Errorf shows formatted error message on stdout without line break at the end.

func Errorln Uses

func Errorln(msg ...interface{})

Errorln message with line break at the end.

func Fatal Uses

func Fatal(msg ...interface{})

Fatal show message with line break at the end and exit to OS.

func HTTPError Uses

func HTTPError(w http.ResponseWriter, code int)

HTTPError write lot to stdout and return json error on http.ResponseWriter with http error code.

func Printf Uses

func Printf(msg ...interface{})

Printf shows formatted message on stdout without line break at the end.

func Println Uses

func Println(msg ...interface{})

Println shows message on stdout with line break at the end.

func RemoveAdapter Uses

func RemoveAdapter(name string)

RemoveAdapter remove the adapter from list

func SetAdapterConfig Uses

func SetAdapterConfig(name string, config map[string]interface{})

SetAdapterConfig allows set new adapter parameters

func Warningf Uses

func Warningf(msg ...interface{})

Warningf shows formatted warning message on stdout without line break at the end.

func Warningln Uses

func Warningln(msg ...interface{})

Warningln shows warning message on stdout with line break at the end.

type AdapterFunc Uses

type AdapterFunc func(m MsgType, o OutType, config map[string]interface{}, msg ...interface{})

AdapterFunc is the type for the function adapter any function that has this signature can be used as an adapter

type AdapterPod Uses

type AdapterPod struct {
    Adapter AdapterFunc
    Config  map[string]interface{}
}

AdapterPod contains the metadata of an adapter

type MsgType Uses

type MsgType uint8

type OutType Uses

type OutType uint8

Directories

PathSynopsis
examples

Package log imports 8 packages (graph) and is imported by 16 packages. Updated 2019-05-23. Refresh now. Tools for package owners.