Documentation ¶
Index ¶
- func Trace(suffix ...interface{}) string
- func TraceIn(suffix ...interface{}) string
- func TraceOut(suffix ...interface{}) string
- type Advisor
- type AmbientContext
- func (ambctx *AmbientContext) Add(errs ...interface{}) *AmbientContext
- func (ambctx *AmbientContext) Dump() chan Error
- func (ambctx *AmbientContext) Handles(errs ...interface{}) *AmbientContext
- func (ambctx *AmbientContext) Log(msgs ...interface{}) *AmbientContext
- func (ambctx *AmbientContext) Trace(suffix ...interface{}) string
- func (ambctx *AmbientContext) TraceIn(suffix ...interface{}) string
- func (ambctx *AmbientContext) TraceOut(suffix ...interface{}) string
- func (ambctx *AmbientContext) With(opcode OpCode) *AmbientContext
- type Collector
- type ConsoleLogger
- func (logChannel ConsoleLogger) Critical(msgs ...interface{}) bool
- func (logChannel ConsoleLogger) Debug(msgs ...interface{}) bool
- func (logChannel ConsoleLogger) Error(msgs ...interface{}) bool
- func (logChannel ConsoleLogger) Fatal(msgs ...interface{}) bool
- func (logChannel ConsoleLogger) Info(msgs ...interface{}) bool
- func (logChannel ConsoleLogger) Panic(msgs ...interface{}) bool
- func (logChannel ConsoleLogger) Warning(msgs ...interface{}) bool
- type DefaultAdvisor
- type ElasticLogger
- func (logChannel ElasticLogger) Critical(msgs ...interface{}) bool
- func (logChannel ElasticLogger) Debug(msgs ...interface{}) bool
- func (logChannel ElasticLogger) Error(msgs ...interface{}) bool
- func (logChannel ElasticLogger) Fatal(msgs ...interface{}) bool
- func (logChannel ElasticLogger) Info(msgs ...interface{}) bool
- func (logChannel ElasticLogger) Panic(msgs ...interface{}) bool
- func (logChannel ElasticLogger) Warning(msgs ...interface{}) bool
- type ErrType
- type Error
- type FileLogger
- func (logChannel FileLogger) Critical(msgs ...interface{}) bool
- func (logChannel FileLogger) Debug(msgs ...interface{}) bool
- func (logChannel FileLogger) Error(msgs ...interface{}) bool
- func (logChannel FileLogger) Fatal(msgs ...interface{}) bool
- func (logChannel FileLogger) Info(msgs ...interface{}) bool
- func (logChannel FileLogger) Panic(msgs ...interface{}) bool
- func (logChannel FileLogger) Warning(msgs ...interface{}) bool
- type Guard
- type LogChannel
- type LogMessage
- type Logger
- func (logger *Logger) Debug(msgs ...interface{}) bool
- func (logger *Logger) Error(msgs ...interface{}) bool
- func (logger *Logger) Info(msgs ...interface{}) bool
- func (logger *Logger) LogWithLevel(level string, msgs ...interface{}) bool
- func (logger *Logger) Send(msgs ...interface{}) bool
- func (logger *Logger) Warning(msgs ...interface{}) bool
- type OpCode
- type Sampler
- type State
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Trace ¶
func Trace(suffix ...interface{}) string
Trace is the generic tracing method one can call, designed to go at any desired place in the code.
Types ¶
type Advisor ¶
type Advisor interface { Static(*ring.Ring) bool Dynamic(<-chan bytes.Buffer) State // contains filtered or unexported methods }
Advisor describes an interface that contains two methods of analyzing a buffer of error values. It provides an abstraction layer over a complicated error state in a system.
func NewAdvisor ¶
NewAdvisor... I'd hate to call it a factory, but it sure seems like one.
type AmbientContext ¶
type AmbientContext struct { Logs *Logger ERR error OK bool // contains filtered or unexported fields }
AmbientContext is the main wrapper for errnie and tries to keep the amount of having to deal with this tool as minimal as possible. I wanted something that I did not have to pass around all the time, cluttering up method signatures and basically being a repetative hassle. I feel in Go's case, having your own favorite way of error handling always at the ready can only be a good thing. And yes, I got inspired (and shamelessly stole) this setup from Viper.
func Add ¶
func Add(errs ...interface{}) *AmbientContext
Add is a proxy method to facilitate shorter style syntax.
func Handles ¶
func Handles(errs ...interface{}) *AmbientContext
Handles is a proxy method to facilitate shorter style syntax.
func Log ¶
func Log(errs ...interface{}) *AmbientContext
Debug is a proxy method to facilitate shorter style syntax. <Deprecated: See proxy referenced implementation>
func New ¶
func New() *AmbientContext
New gives us back a reference to the instance, so we should be able to call the package anywhere we want in our host code.
func (*AmbientContext) Add ¶
func (ambctx *AmbientContext) Add(errs ...interface{}) *AmbientContext
Add the errors to the internal error collector, a ring buffer that will keep them in memory so the can be used in combination with an Advisor, together providing a mechanism to judge state (`health`) of a chain od methods.
func (*AmbientContext) Dump ¶
func (ambctx *AmbientContext) Dump() chan Error
Dump errnie's internal error collector out to the log receiver, which could be anything from the local console to a log data store. This actually returns a channel of errnie's internal Error type, which is a razor thin wrapper around Go's error type, value, no, type... Errors are Weird (not values).
func (*AmbientContext) Handles ¶
func (ambctx *AmbientContext) Handles(errs ...interface{}) *AmbientContext
Handles the error in some semi-significant want so we don't have to think too much about it and sets the err and ok values so we can do some nifty syntactical sugar tricks upstream.
func (*AmbientContext) Log ¶
func (ambctx *AmbientContext) Log(msgs ...interface{}) *AmbientContext
Log a list of errors or any other object you want to inspect. Good use-cases for this method are info or debug lines. Maybe errors you don't care about handling, but I would suggest using a no-op handler for that. <Deprecated, use the new format: `errnie.Logs.Error(x)`> (Error(x) can be replaced with any of errnie's known log levels.)
func (*AmbientContext) Trace ¶
func (ambctx *AmbientContext) Trace(suffix ...interface{}) string
Trace is the proxied method described above with a similar name.
func (*AmbientContext) TraceIn ¶
func (ambctx *AmbientContext) TraceIn(suffix ...interface{}) string
TraceIn is the proxied method described above with a similar name.
func (*AmbientContext) TraceOut ¶
func (ambctx *AmbientContext) TraceOut(suffix ...interface{}) string
TraceOut is the proxied method described above with a similar name.
func (*AmbientContext) With ¶
func (ambctx *AmbientContext) With(opcode OpCode) *AmbientContext
With is a method to chain onto a previous method (most likely `Handles`) and designed to specify the type of action to take when an error has been detected.
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector saves Errors in a ring buffer.
func NewCollector ¶
NewCollector sets up the ring buffer we will collect our errors in.
type ConsoleLogger ¶
type ConsoleLogger struct{}
ConsoleLogger is a canonical implementation of the LogChannel interface, and provides the basic local terminal output for log messages.
func (ConsoleLogger) Critical ¶
func (logChannel ConsoleLogger) Critical(msgs ...interface{}) bool
func (ConsoleLogger) Debug ¶
func (logChannel ConsoleLogger) Debug(msgs ...interface{}) bool
Debug shows a muted colored message in the terminal when `debug: true` in the host program's config file.
func (ConsoleLogger) Error ¶
func (logChannel ConsoleLogger) Error(msgs ...interface{}) bool
func (ConsoleLogger) Fatal ¶
func (logChannel ConsoleLogger) Fatal(msgs ...interface{}) bool
func (ConsoleLogger) Info ¶
func (logChannel ConsoleLogger) Info(msgs ...interface{}) bool
func (ConsoleLogger) Panic ¶
func (logChannel ConsoleLogger) Panic(msgs ...interface{}) bool
func (ConsoleLogger) Warning ¶
func (logChannel ConsoleLogger) Warning(msgs ...interface{}) bool
type DefaultAdvisor ¶
type DefaultAdvisor struct {
// contains filtered or unexported fields
}
DefaultAdvisor is the built in and most basic implementation of the concept.
type ElasticLogger ¶
type ElasticLogger struct {
// contains filtered or unexported fields
}
func (ElasticLogger) Critical ¶
func (logChannel ElasticLogger) Critical(msgs ...interface{}) bool
func (ElasticLogger) Debug ¶
func (logChannel ElasticLogger) Debug(msgs ...interface{}) bool
func (ElasticLogger) Error ¶
func (logChannel ElasticLogger) Error(msgs ...interface{}) bool
func (ElasticLogger) Fatal ¶
func (logChannel ElasticLogger) Fatal(msgs ...interface{}) bool
func (ElasticLogger) Info ¶
func (logChannel ElasticLogger) Info(msgs ...interface{}) bool
func (ElasticLogger) Panic ¶
func (logChannel ElasticLogger) Panic(msgs ...interface{}) bool
func (ElasticLogger) Warning ¶
func (logChannel ElasticLogger) Warning(msgs ...interface{}) bool
type Error ¶
Error wraps Go's built in error type to extend its functionality with a severity level.
type FileLogger ¶
type FileLogger struct{}
func (FileLogger) Critical ¶
func (logChannel FileLogger) Critical(msgs ...interface{}) bool
func (FileLogger) Debug ¶
func (logChannel FileLogger) Debug(msgs ...interface{}) bool
func (FileLogger) Error ¶
func (logChannel FileLogger) Error(msgs ...interface{}) bool
func (FileLogger) Fatal ¶
func (logChannel FileLogger) Fatal(msgs ...interface{}) bool
func (FileLogger) Info ¶
func (logChannel FileLogger) Info(msgs ...interface{}) bool
func (FileLogger) Panic ¶
func (logChannel FileLogger) Panic(msgs ...interface{}) bool
func (FileLogger) Warning ¶
func (logChannel FileLogger) Warning(msgs ...interface{}) bool
type Guard ¶
type Guard struct { Err error // contains filtered or unexported fields }
Guard is a way to override any existing interrupt messages such as panics and recover from them either silently or by invoking a custom recovery function.
func NewGuard ¶
func NewGuard(handler func()) *Guard
NewGuard constructs an instance of a guard that can live basically anywhere and sit ready to either Check or Rescue.
type LogChannel ¶
type LogChannel interface { Panic(msgs ...interface{}) bool Fatal(msgs ...interface{}) bool Critical(msgs ...interface{}) bool Error(msgs ...interface{}) bool Info(msgs ...interface{}) bool Warning(msgs ...interface{}) bool Debug(msgs ...interface{}) bool }
func NewConsoleLogger ¶
func NewConsoleLogger() LogChannel
func NewElasticLogger ¶
func NewElasticLogger() LogChannel
func NewFileLogger ¶
func NewFileLogger() LogChannel
type LogMessage ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a custom logger which allows a consistent interface to multiple output channels.
var Logs *Logger
func NewLogger ¶
func NewLogger(channels ...LogChannel) *Logger
func (*Logger) LogWithLevel ¶
type OpCode ¶
type OpCode uint
OpCode is a type that can be used to identify an intent when using errnie as the handler of one or multiple errors. To use it you need to use the `errnie.Handles()` and wrap it around the error. To use errnie's built-in handlers you can use it `in the middle` like so:
```go errnie.Handles(err).With(errnie.KILL) ```
in which case you have chosen to exit the program if the error was not nil.
const ( // NOOP is the empty value for this enumerable type and does nothing. NOOP OpCode = iota // KILL wraps the error and if triggered will exit the program. KILL // RECV attempts to recover the program from any kind of error. RECV // RETR will attempt a retry of the previous operation. RETR // RTRN will return out of the current method. RTRN )
type State ¶
type State uint
State defines an enumerable type of 4 arbitrary values of degradation. Use them however suits you.
type Tracer ¶
type Tracer struct{}
Tracer provides some basic stack tracing features at the moment which expose the method chains that are in use for any given operation. This is planned to be extended quite a bit in the near future.