Documentation ¶
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 (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
- type LogContext
- type LogMethod
- type 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 (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)
Constants ¶
const ( LevelDebug = iota LevelInfo = iota LevelWarning = iota LevelError = iota )
Config severity integers.
const ( LevelNameDebug = "debug" LevelNameInfo = "info" LevelNameWarning = "warning" LevelNameError = "error" )
Config severity names.
Variables ¶
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, } )
Seveirty name->integer map.
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") )
Errors
Functions ¶
func AddAdapter ¶
func AddAdapter(name string, la LogAdapter)
func ClearAdapters ¶
func ClearAdapters()
func GetDefaultAdapterName ¶
func GetDefaultAdapterName() string
Return the current default adapter name.
func Is ¶
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 PrintError ¶
func PrintError(err error)
Print is a utility function to prevent the caller from having to import the third-party library.
func PrintErrorf ¶
PrintErrorf is a utility function to prevent the caller from having to import the third-party library.
func SetDefaultAdapterName ¶
func SetDefaultAdapterName(name string)
The adapter will automatically be the first one registered. This overrides that.
Types ¶
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 ¶
type EnvironmentConfigurationProvider struct { }
Environment configuration-provider.
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 LogMethod ¶
type LogMethod func(lc *LogContext, message *string) error
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) Adapter ¶
func (l *Logger) Adapter() LogAdapter
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 StaticConfigurationProvider ¶
type StaticConfigurationProvider struct {
// contains filtered or unexported fields
}
Static configuration-provider.
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)