Documentation ¶
Overview ¶
Package log provides logging interfaces for use in handlers and loggers for stdout, files, and time series databases
Index ¶
- Constants
- func Add(l PrintLogger)
- func AddTag(values map[string]interface{}, key string, value string) map[string]interface{}
- func AddValuesLog(l ValuesLogger)
- func Printf(format string, args ...interface{})
- func Timef(start time.Time, format string, args ...interface{})
- func Values(values map[string]interface{})
- func ValuesBatch(values []map[string]interface{})
- type Default
- type File
- type PrintLogger
- type StatsLog
- type ValuesLogger
Constants ¶
const ( // FileFlags serts the flags for OpenFile on the log file FileFlags = os.O_WRONLY | os.O_APPEND | os.O_CREATE // FilePermissions serts the perms for OpenFile on the log file FilePermissions = 0640 )
const ( // PrefixDate constant for date prefixes PrefixDate = "2006-01-02 " // PrefixTime constants for time prefix PrefixTime = "15:04:05 " // PrefixDateTime constants for date + time prefix PrefixDateTime = "2006-01-02:15:04:05 " )
Date prefix constants
const ( ColorNone = "\033[0m" // Use this to clear output ColorRed = "\033[31m" ColorGreen = "\033[32m" ColorAmber = "\033[33m" ColorCyan = "\033[1;36m" )
Color constants used for writing in colored output
const KeyNameTime = "stats_key_name_time"
KeyNameTime specifies a key used to define the time value for a given key the Value should be a time.Time value
const SeriesName = "stats_series_name"
SeriesName specifies the key used to define which bucket/table to send values to thius is used by adapters to extract the table name from values supplied.
const TagPrefix = "stats_key_tag_"
TagPrefix for a key name allows adding a tag instead of a field to influx
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(l PrintLogger)
Add adds the given logger to the list of outputs, it should be called before logging commences
func AddValuesLog ¶
func AddValuesLog(l ValuesLogger)
AddValuesLog adds the given logger to the list of ValuesLoggers, it should be called before logging commences
func Timef ¶
Timef prints the time elapsed since start plus any message to the PrintLog to log time taken by a function, call at start with defer log.Timef(start,...).
func Values ¶
func Values(values map[string]interface{})
Values values to the valueLogs which typically emit stats to a time series database.
func ValuesBatch ¶
func ValuesBatch(values []map[string]interface{})
ValuesBatch sends an array of values to the valueLogs which typically emit stats to a time series database.
Types ¶
type Default ¶
type Default struct { // PrefixTimeFormat is used to prefix any log lines emitted with a time. PrefixTimeFormat string // Writer is the output of this logger. Writer io.Writer }
Default defines a default logger to stdout
func (*Default) WriteString ¶
WriteString writes the string to the Writer.
type PrintLogger ¶
type PrintLogger interface {
Printf(format string, args ...interface{})
}
PrintLogger defines an interface for logging to a text log.
type StatsLog ¶
type StatsLog struct { }
StatsLog conforms to the ValuesLogger interface It simply outputs the values to stdout, rather than logging to a specific service see the adapters folder for ValueLoggers which connect to time series databases.
type ValuesLogger ¶
type ValuesLogger interface { Values(values map[string]interface{}) ValuesBatch(values []map[string]interface{}) }
ValuesLogger defines an interface for logging to a stats service.