tango.util.log.Log

Members

Aliases

Arg
alias Arg = void*

Platform issues ...

Arg
alias Arg = void*
Undocumented in source.
Arg
alias Arg = void*
Undocumented in source.
ArgList
alias ArgList = va_list

Platform issues ...

ArgList
alias ArgList = va_list
Undocumented in source.
ArgList
alias ArgList = void*
Undocumented in source.
Level
alias Level = ILogger.Level

These represent the standard LOG4J event levels. Note that Debug is called Trace here, because debug is a reserved word in D

Classes

AppendNull
class AppendNull

An appender that does nothing. This is useful for cutting and pasting, and for benchmarking the tango.log environment.

AppendStream
class AppendStream

Append to a configured OutputStream

Appender
class Appender

Base class for all Appenders. These objects are responsible for emitting messages sent to a particular logger. There may be more than one appender attached to any logger. The actual message is constructed by another class known as an EventLayout.

LayoutTimer
class LayoutTimer

A simple layout comprised only of time(ms), level, name, and message

Logger
class Logger

Loggers are named entities, sometimes shared, sometimes specific to a particular portion of code. The names are generally hierarchical in nature, using dot notation (with '.') to separate each named section. For example, a typical name might be something like "mail.send.writer"

Functions

main
void main()

Structs

Log
struct Log

Manager for routing Logger calls to the default hierarchy. Note that you may have multiple hierarchies per application, but must access the hierarchy directly for root() and lookup() methods within each additional instance.

LogEvent
struct LogEvent

Contains all information about a logging event, and is passed around between methods once it has been determined that the invoking logger is enabled for output.

Meta

License

BSD style: $(LICENSE)

Version

May 2004 : Initial release Oct 2004: Hierarchy moved due to circular dependencies Apr 2008: Lazy delegates removed due to awkward usage

Authors

Kris

Simplified, pedestrian usage:

import tango.util.log.Config;

Log ("hello world");
Log ("temperature is {} degrees", 75);

Generic usage:

Loggers are named entities, sometimes shared, sometimes specific to a particular portion of code. The names are generally hierarchical in nature, using dot notation (with '.') to separate each named section. For example, a typical name might be something like "mail.send.writer"

import tango.util.log.Log;

auto log = Log.lookup ("mail.send.writer");

log.info  ("an informational message");
log.error ("an exception message: {}", exception);

etc ...

It is considered good form to pass a logger instance as a function or class-ctor argument, or to assign a new logger instance during static class construction. For example: if it were considered appropriate to have one logger instance per class, each might be constructed like so:

private Logger log;

static this()
{
    log = Log.lookup (nameOfThisClassOrStructOrModule);
}

Messages passed to a Logger are assumed to be either self-contained or configured with "{}" notation a la Layout & Stdout:

log.warn ("temperature is {} degrees!", 101);

Note that an internal workspace is used to format the message, which is limited to 2000 bytes. Use "{.256}" truncation notation to limit the size of individual message components, or use explicit formatting:

char[4096] buf = void;

log.warn (log.format (buf, "a very long message: {}", someLongMessage));

To avoid overhead when constructing arguments passed to formatted messages, you should check to see whether a logger is active or not:

if (log.warn)
    log.warn ("temperature is {} degrees!", complexFunction());

tango.log closely follows both the API and the behaviour as documented at the official Log4J site, where you'll find a good tutorial. Those pages are hosted over <A HREF="http://logging.apache.org/log4j/docs/documentation.html">here</A>.