Inspirel banner

Programming Distributed Systems with YAMI4

8.3.2 Logging

There is no provision for internal event logging in the Python library.

The Ada and C++ libraries offer the possibility to report internal events to user-provided callback implementations of a dedicated interface - the interface is called event_callback in the C++ library and appropriate Ada definitions are grouped in the YAMI.Event_Notification_Handlers package.

The following events are reported via these interfaces:

In addition to these interfaces, default implementations of activity monitors are provided that implement these interfaces. The activity monitors can be also accessed as regular remote objects and as such can be used as simple sources of activity statistics for both in-process and remote inspection.

The Java and .NET libraries offer the possibility to report internal events with various verbosity.

In Java, the LogCallback interface provides a foundation for the user-provided callback implementations and LogCallback.LogLevel enumerations allow to select the required level of verbosity. The callback implementation can be provided to the agent's constructor and is fixed for the agent's lifetime.

The following is an example of simple user-defined log callback and its use with the agent constructor:

    private static class MyLogSink implements LogCallback {
        @Override
        public void log(LogLevel level, String msg) {
            System.out.println(level.toString() + ": " + msg);
        }
    }

    // ...

    agent = new Agent(options,
        new MyLogSink(), LogCallback.LogLevel.MEDIUM);

Three levels of event logging are defined in the LogCallback.LogLevel enumeration type:

LOW, which reports on the following events:

MEDIUM, which reports all events of the LOW level and adds the following events:

HIGH, which reports all events of the LOW and MEDIUM levels and adds the following:

Note:

The log callback can be used as a hook for integration with external logging frameworks like log4j. The YAMI4 library, as such, has no dependency on any external logging mechanism.

In .NET programs log events can be propagated to the user code by means of a delegate, which can be installed with one of the agent's constructor. The LogEventArgs class, together with its nested LogLevel enumeration type, define the protocol for passing log information to the user. Further delegates can be added to the agent's logging system at run-time with the help of the publicly available Log event. The granularity and meaning of logging levels is exactly as described above for the Java library.