Documentation ¶
Overview ¶
com - classified output messages | A communication library as addition to fmt and log. The focus is solely to ease manipulation of printing messages to io.Writer's with different purpose (stderr/stdout/files), verbosity levels (from silent to debug) and expressiveness in declaration.
Index ¶
- Constants
- Variables
- type Config
- func (c *Config) Custom(prefixes, suffixes map[Level]string)
- func (c *Config) D() *Config
- func (c *Config) Debug() *Config
- func (c *Config) E() *Config
- func (c *Config) Error() *Config
- func (c *Config) L(runlevel Level) *Config
- func (c *Config) Level(runlevel Level) *Config
- func (c *Config) LevelIs() Level
- func (c *Config) Logger(level Level, name string, err bool) *log.Logger
- func (c *Config) Print(msg ...interface{}) (n int, err error)
- func (c *Config) Printf(format string, msg ...interface{}) (n int, err error)
- func (c *Config) Println(msg ...interface{}) (n int, err error)
- func (c *Config) Reset(setting Level)
- func (c *Config) TimestampDisable()
- func (c *Config) TimestampEnable(format string)
- func (c *Config) V() *Config
- func (c *Config) Verbose() *Config
- type Level
- type Output
Constants ¶
const ( // a special Level - no output at all Silent Level = iota // Common Level / default Common // dedicated Levels Verbose = 128 // print all messages with additional info Debug = 254 // print only errors, but all errors ErrorsOnly = 255 )
const ( D = Debug E = ErrorsOnly C = Common S = Silent V = Verbose )
shortcuts
Variables ¶
var ( Stdout = os.Stdout Stderr = os.Stderr PrefixDebug = "[Debug] " PrefixError = "[Error] " )
Default values for Config creation through New()
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config behaviour can be manipulated through the global variables before New() call.
func (*Config) Logger ¶
Logger enables you to handle the logged output through the com.Config type. You have to pre-decide if it's handled like an error or normal log value and on which Level.
func (*Config) Print ¶
Print writes to c.out or c.err depending on c.shift, if the given Level is set.
func (*Config) Printf ¶
Printf formats according to a format specifier and writes to c.out or c.err depending on c.shift, if the given Level is set.
func (*Config) Println ¶
Println writes to c.out or c.err depending on c.shift and appends a newline on msg, if the given Level is set.
func (*Config) TimestampDisable ¶
func (c *Config) TimestampDisable()
TimestampDisable deactivates all timestamps.
func (*Config) TimestampEnable ¶
TimestampEnable activates timestamps for all output including logging to the format or defaults to "2006-01-02|15:04:05|-0700[MST]|".