...

Package log

import "github.com/dsoprea/go-logging"
Overview
Index
Subdirectories

Overview ▾

Index ▾

Constants
Variables
func AddAdapter(name string, la LogAdapter)
func AddExcludeFilter(noun string)
func AddIncludeFilter(noun string)
func ClearAdapters()
func Errorf(message string, args ...interface{}) *errors.Error
func GetDefaultAdapterName() string
func Is(actual, against error) bool
func IsConfigurationLoaded() bool
func LoadConfiguration(cp ConfigurationProvider)
func Panic(err interface{})
func PanicIf(err interface{})
func Panicf(message string, args ...interface{})
func PrintError(err error)
func PrintErrorf(err error, format string, args ...interface{})
func RemoveExcludeFilter(noun string)
func RemoveIncludeFilter(noun string)
func SetDefaultAdapterName(name string)
func Wrap(err interface{}) *errors.Error
type ConfigurationProvider
type ConsoleLogAdapter
    func (cla *ConsoleLogAdapter) Debugf(lc *LogContext, message *string) error
    func (cla *ConsoleLogAdapter) Errorf(lc *LogContext, message *string) error
    func (cla *ConsoleLogAdapter) Infof(lc *LogContext, message *string) error
    func (cla *ConsoleLogAdapter) Warningf(lc *LogContext, message *string) error
type EnvironmentConfigurationProvider
    func NewEnvironmentConfigurationProvider() *EnvironmentConfigurationProvider
    func (ecp *EnvironmentConfigurationProvider) DefaultAdapterName() string
    func (ecp *EnvironmentConfigurationProvider) ExcludeBypassLevelName() string
    func (ecp *EnvironmentConfigurationProvider) ExcludeNouns() string
    func (ecp *EnvironmentConfigurationProvider) Format() string
    func (ecp *EnvironmentConfigurationProvider) IncludeNouns() string
    func (ecp *EnvironmentConfigurationProvider) LevelName() string
type LogAdapter
    func NewConsoleLogAdapter() LogAdapter
type LogContext
type LogMethod
type Logger
    func NewLogger(noun string) (l *Logger)
    func NewLoggerWithAdapterName(noun string, adapterName string) (l *Logger)
    func (l *Logger) Adapter() LogAdapter
    func (l *Logger) Debugf(ctx context.Context, format string, args ...interface{})
    func (l *Logger) ErrorIff(ctx context.Context, errRaw interface{}, format string, args ...interface{})
    func (l *Logger) Errorf(ctx context.Context, errRaw interface{}, format string, args ...interface{})
    func (l *Logger) Infof(ctx context.Context, format string, args ...interface{})
    func (l *Logger) Noun() string
    func (l *Logger) PanicIff(ctx context.Context, errRaw interface{}, format string, args ...interface{})
    func (l *Logger) Panicf(ctx context.Context, errRaw interface{}, format string, args ...interface{})
    func (l *Logger) Warningf(ctx context.Context, format string, args ...interface{})
type MessageContext
type StaticConfigurationProvider
    func NewStaticConfigurationProvider() *StaticConfigurationProvider
    func (scp *StaticConfigurationProvider) DefaultAdapterName() string
    func (scp *StaticConfigurationProvider) ExcludeBypassLevelName() string
    func (scp *StaticConfigurationProvider) ExcludeNouns() string
    func (scp *StaticConfigurationProvider) Format() string
    func (scp *StaticConfigurationProvider) IncludeNouns() string
    func (scp *StaticConfigurationProvider) LevelName() string
    func (scp *StaticConfigurationProvider) SetDefaultAdapterName(adapterName string)
    func (scp *StaticConfigurationProvider) SetExcludeBypassLevelName(excludeBypassLevelName string)
    func (scp *StaticConfigurationProvider) SetExcludeNouns(excludeNouns string)
    func (scp *StaticConfigurationProvider) SetFormat(format string)
    func (scp *StaticConfigurationProvider) SetIncludeNouns(includeNouns string)
    func (scp *StaticConfigurationProvider) SetLevelName(levelName string)

Package files

config.go console_adapter.go log.go

Constants

Config severity integers.

const (
    LevelDebug   = iota
    LevelInfo    = iota
    LevelWarning = iota
    LevelError   = iota
)

Config severity names.

const (
    LevelNameDebug   = "debug"
    LevelNameInfo    = "info"
    LevelNameWarning = "warning"
    LevelNameError   = "error"
)

Variables

Seveirty name->integer map.

var (
    LevelNameMap = map[string]int{
        LevelNameDebug:   LevelDebug,
        LevelNameInfo:    LevelInfo,
        LevelNameWarning: LevelWarning,
        LevelNameError:   LevelError,
    }

    LevelNameMapR = map[int]string{
        LevelDebug:   LevelNameDebug,
        LevelInfo:    LevelNameInfo,
        LevelWarning: LevelNameWarning,
        LevelError:   LevelNameError,
    }
)

Errors

var (
    ErrAdapterAlreadyRegistered = e.New("adapter already registered")
    ErrFormatEmpty              = e.New("format is empty")
    ErrExcludeLevelNameInvalid  = e.New("exclude bypass-level is invalid")
    ErrNoAdapterConfigured      = e.New("no default adapter configured")
    ErrAdapterIsNil             = e.New("adapter is nil")
    ErrConfigurationNotLoaded   = e.New("can not configure because configuration is not loaded")
)

func AddAdapter

func AddAdapter(name string, la LogAdapter)

func AddExcludeFilter

func AddExcludeFilter(noun string)

Add global exclude filter.

func AddIncludeFilter

func AddIncludeFilter(noun string)

Add global include filter.

func ClearAdapters

func ClearAdapters()

func Errorf

func Errorf(message string, args ...interface{}) *errors.Error

func GetDefaultAdapterName

func GetDefaultAdapterName() string

Return the current default adapter name.

func Is

func Is(actual, against error) bool

Is checks if the left ("actual") error equals the right ("against") error. The right must be an unwrapped error (the kind that you'd initialize as a global variable). The left can be a wrapped or unwrapped error.

func IsConfigurationLoaded

func IsConfigurationLoaded() bool

func LoadConfiguration

func LoadConfiguration(cp ConfigurationProvider)

func Panic

func Panic(err interface{})

func PanicIf

func PanicIf(err interface{})

func Panicf

func Panicf(message string, args ...interface{})

func PrintError

func PrintError(err error)

Print is a utility function to prevent the caller from having to import the third-party library.

func PrintErrorf

func PrintErrorf(err error, format string, args ...interface{})

PrintErrorf is a utility function to prevent the caller from having to import the third-party library.

func RemoveExcludeFilter

func RemoveExcludeFilter(noun string)

Remove global exclude filter.

func RemoveIncludeFilter

func RemoveIncludeFilter(noun string)

Remove global include filter.

func SetDefaultAdapterName

func SetDefaultAdapterName(name string)

The adapter will automatically be the first one registered. This overrides that.

func Wrap

func Wrap(err interface{}) *errors.Error

type ConfigurationProvider

type ConfigurationProvider interface {
    // Alternative format (defaults to .
    Format() string

    // Alternative adapter (defaults to "appengine").
    DefaultAdapterName() string

    // Alternative level at which to display log-items (defaults to
    // "info").
    LevelName() string

    // Configuration-driven comma-separated list of nouns to include. Defaults
    // to empty.
    IncludeNouns() string

    // Configuration-driven comma-separated list of nouns to exclude. Defaults
    // to empty.
    ExcludeNouns() string

    // Level at which to disregard exclusion (if the severity of a message
    // meets or exceed this, always display). Defaults to empty.
    ExcludeBypassLevelName() string
}

type ConsoleLogAdapter

type ConsoleLogAdapter struct {
}

func (*ConsoleLogAdapter) Debugf

func (cla *ConsoleLogAdapter) Debugf(lc *LogContext, message *string) error

func (*ConsoleLogAdapter) Errorf

func (cla *ConsoleLogAdapter) Errorf(lc *LogContext, message *string) error

func (*ConsoleLogAdapter) Infof

func (cla *ConsoleLogAdapter) Infof(lc *LogContext, message *string) error

func (*ConsoleLogAdapter) Warningf

func (cla *ConsoleLogAdapter) Warningf(lc *LogContext, message *string) error

type EnvironmentConfigurationProvider

Environment configuration-provider.

type EnvironmentConfigurationProvider struct {
}

func NewEnvironmentConfigurationProvider

func NewEnvironmentConfigurationProvider() *EnvironmentConfigurationProvider

func (*EnvironmentConfigurationProvider) DefaultAdapterName

func (ecp *EnvironmentConfigurationProvider) DefaultAdapterName() string

func (*EnvironmentConfigurationProvider) ExcludeBypassLevelName

func (ecp *EnvironmentConfigurationProvider) ExcludeBypassLevelName() string

func (*EnvironmentConfigurationProvider) ExcludeNouns

func (ecp *EnvironmentConfigurationProvider) ExcludeNouns() string

func (*EnvironmentConfigurationProvider) Format

func (ecp *EnvironmentConfigurationProvider) Format() string

func (*EnvironmentConfigurationProvider) IncludeNouns

func (ecp *EnvironmentConfigurationProvider) IncludeNouns() string

func (*EnvironmentConfigurationProvider) LevelName

func (ecp *EnvironmentConfigurationProvider) LevelName() string

type LogAdapter

type LogAdapter interface {
    Debugf(lc *LogContext, message *string) error
    Infof(lc *LogContext, message *string) error
    Warningf(lc *LogContext, message *string) error
    Errorf(lc *LogContext, message *string) error
}

func NewConsoleLogAdapter

func NewConsoleLogAdapter() LogAdapter

type LogContext

type LogContext struct {
    Logger *Logger
    Ctx    context.Context
}

type LogMethod

type LogMethod func(lc *LogContext, message *string) error

type Logger

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

func NewLogger

func NewLogger(noun string) (l *Logger)

func NewLoggerWithAdapterName

func NewLoggerWithAdapterName(noun string, adapterName string) (l *Logger)

func (*Logger) Adapter

func (l *Logger) Adapter() LogAdapter

func (*Logger) Debugf

func (l *Logger) Debugf(ctx context.Context, format string, args ...interface{})

func (*Logger) ErrorIff

func (l *Logger) ErrorIff(ctx context.Context, errRaw interface{}, format string, args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(ctx context.Context, errRaw interface{}, format string, args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(ctx context.Context, format string, args ...interface{})

func (*Logger) Noun

func (l *Logger) Noun() string

func (*Logger) PanicIff

func (l *Logger) PanicIff(ctx context.Context, errRaw interface{}, format string, args ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(ctx context.Context, errRaw interface{}, format string, args ...interface{})

func (*Logger) Warningf

func (l *Logger) Warningf(ctx context.Context, format string, args ...interface{})

type MessageContext

TODO(dustin): !! Also populate whether we've bypassed an exception so that

we can add a template macro to prefix an exclamation of
some sort.
type MessageContext struct {
    Level         *string
    Noun          *string
    Message       *string
    ExcludeBypass bool
}

type StaticConfigurationProvider

Static configuration-provider.

type StaticConfigurationProvider struct {
    // contains filtered or unexported fields
}

func NewStaticConfigurationProvider

func NewStaticConfigurationProvider() *StaticConfigurationProvider

func (*StaticConfigurationProvider) DefaultAdapterName

func (scp *StaticConfigurationProvider) DefaultAdapterName() string

func (*StaticConfigurationProvider) ExcludeBypassLevelName

func (scp *StaticConfigurationProvider) ExcludeBypassLevelName() string

func (*StaticConfigurationProvider) ExcludeNouns

func (scp *StaticConfigurationProvider) ExcludeNouns() string

func (*StaticConfigurationProvider) Format

func (scp *StaticConfigurationProvider) Format() string

func (*StaticConfigurationProvider) IncludeNouns

func (scp *StaticConfigurationProvider) IncludeNouns() string

func (*StaticConfigurationProvider) LevelName

func (scp *StaticConfigurationProvider) LevelName() string

func (*StaticConfigurationProvider) SetDefaultAdapterName

func (scp *StaticConfigurationProvider) SetDefaultAdapterName(adapterName string)

func (*StaticConfigurationProvider) SetExcludeBypassLevelName

func (scp *StaticConfigurationProvider) SetExcludeBypassLevelName(excludeBypassLevelName string)

func (*StaticConfigurationProvider) SetExcludeNouns

func (scp *StaticConfigurationProvider) SetExcludeNouns(excludeNouns string)

func (*StaticConfigurationProvider) SetFormat

func (scp *StaticConfigurationProvider) SetFormat(format string)

func (*StaticConfigurationProvider) SetIncludeNouns

func (scp *StaticConfigurationProvider) SetIncludeNouns(includeNouns string)

func (*StaticConfigurationProvider) SetLevelName

func (scp *StaticConfigurationProvider) SetLevelName(levelName string)

Subdirectories

Name Synopsis
..
v2