Documentation ¶
Index ¶
- func Level(info event.Info, w io.Writer) (int, error)
- func LoggerName(info event.Info, w io.Writer) (int, error)
- func Message(info event.Info, w io.Writer) (int, error)
- func RegisterRenderer(name string, r LayoutRenderer)
- type BaseDir
- type DateTime
- type LayoutFunc
- type LayoutRenderer
- type LayoutRendererWithParameters
- type Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggerName ¶
LoggerName writes info.Source.LoggerName() to w
func RegisterRenderer ¶
func RegisterRenderer(name string, r LayoutRenderer)
RegisterRenderer takes a name and an instance of a LayoutRenderer and registers it so that the name can be used in layout templates.
If r also implements LayoutRendererWithParameters then r.CreateLayoutRenderer will be called to create a new instance of the LayoutRenderer if the template specifies any parameters
Types ¶
type BaseDir ¶
type BaseDir struct {
// contains filtered or unexported fields
}
BaseDir renders the directory of the executable relative to the current working directory and is typically useful for specifying where to save log files
Example:
"filename": "${basedir}/logs/debug.log"
type DateTime ¶
type DateTime struct {
// contains filtered or unexported fields
}
func (*DateTime) CreateLayoutRenderer ¶
func (dt *DateTime) CreateLayoutRenderer(parameters map[string]string) (LayoutRenderer, error)
type LayoutFunc ¶
The LayoutFunc type is an adapter to allow the use of ordinary functions as layout renderers. If f is a function with the appropriate signature, LayoutFunc(f) is a LayoutRenderer that calls f.
type LayoutRenderer ¶
type LayoutRenderer interface { // Write takes the information in info and writes it to w. The return values are // the number of bytes written and any error that occurred. Write(info event.Info, w io.Writer) (int, error) // IsDynamic returns false if the data written by Write is static throughout the // course of the applications lifetime. It returns true otherwise. IsDynamic() bool }
LayoutRenderer is the interface that wraps a layout renderer.
When creating custom renderers, this is the interface that needs to be implemented.
type LayoutRendererWithParameters ¶
type LayoutRendererWithParameters interface {
CreateLayoutRenderer(parameters map[string]string) (LayoutRenderer, error)
}
LayoutRendererWithParameters is the interface which wraps a LayoutRenderer factory such that parameters can be specified in the layout
Custom LayoutRenderers will typically also implement this interface if its behaviour can be customized