The OpenD Programming Language

LoggerOf

The arsd.core logger works differently than many in that it works as a ring buffer of objects that are consumed (or missed; buffer overruns are possible) by a different thread instead of as strings written to some file.

A library (or an application) defines a log source. They write to this source.

Applications then define log sinks, zero or more, which reads from various sources and does something with them.

Log calls, in this sense, are quite similar to asynchronous events that can be subscribed to by event handlers. The difference is events are generally not dropped - they might coalesce but are usually not just plain dropped in a buffer overrun - whereas logs can be. If the log consumer can't keep up, the details are just lost. The log producer will not wait for the consumer to catch up.

More...
mixin template LoggerOf (
T
) {}

Detailed Description

An application can also set a default subscriber which applies to all log objects throughout.

All log message objects must be capable of being converted to strings and to json.

Ad-hoc messages can be done with interpolated sequences.

Messages automatically get a timestamp. They can also have file/line and maybe even a call stack.

Examples

mixin LoggerOf!X mylogger;

mylogger.log(i"$this heartbeat"); // creates an ad-hoc log message

Meta

History

Added May 27, 2024