Documentation ¶
Overview ¶
catlogger is derived from the JavaScript package categorical-logger, which can be found at https://github.com/openlibraryenvironment/categorical-logger The present version of this library falls short of its ancestor in two respects:
- It does not support logging functional arguments
- It does not have the the setter methods
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an opaque structure created by MakeLogger and which encapsulates the configuration passed into that function. Typically a program will make just one of these, and pass it around as necessary.
func MakeLogger ¶
MakeLogger creates a catlogger object on which the Log method may subsequently be called. The logger is configured by three parameters:
categories: a string containing zero or more comma-separated logging categories, such as "init,config,url", for which the logger should emit messages. There is no predefined list of categegories, and no hierarchy between categories -- unlike the FATAL, ERROR, WARN, INFO, DEBUG hierarchy in log4j and similar libraries. Applications can use whatever categories they wish.
prefix: a short string or nil. If the former, then it is included at the start of each log message.
timestamp: a boolean indicating whether or not a timestamp is to be included in each log message
func (*Logger) HasCategory ¶
HasCategory returns true is the logger has been configured to include the named category and false if not.
func (*Logger) Log ¶
Log does nothing if the named category is not among those that the logger is configured to use. But if the logged is configured to include the category, then it logs a message to standard error, consisting of the logger prefix (if defined), a timestamp (if configured), and all the supplied strings, separated by spaces and terminated by a newline.