Log Entry

The smallest entity in a log is an event, which represents the execution of an activity. Additionally to the activity name it carries information like time of execution, originator (usually a person or system responsible for the activity execution), the originator’s role, and an event type. The log entry is defined in the class LogEntry and the event types are defined in the enumeration EventType.

The following code defines two log entries:

LogEntry entryA = new LogEntry("act_1");
entryA.setEventType(EventType.start);
entryA.setOriginator("sub_1");
entryA.setRole("r1");
entryA.setTimestamp(new Date(1445405280000l));

System.out.println(entryA);

LogEntry entryB = new LogEntry("act_2");
entryB.setEventType(EventType.complete);
entryB.setOriginator("sub_1");
entryB.setRole("r1");
entryB.setTimestamp(new Date(499161600000l));

System.out.println(entryB);

This code sample produces the following output:

[10/21/2015 07:28:00|act_2|sub_1]
[10/26/1986 09:00:00|act_1|sub_1]

Log entries can be enriched with meta information in form of DataAttributes. Data attributes have a string key and a value of type Object. The following code adds event descriptions to log entries:

entryA.addMetaAttribute(new DataAttribute(
    "desc",

    "Marty McFly hits the road to the year 1985." ));
entryB.addMetaAttribute(new DataAttribute(

    "desc",
    "Marty McFly arrives at the year 1985." ));

To prevent editing of fields of the log entry, they can be locked. If a setter gets called for a locked field the method throws a LockingException. The following code locks the log entry’s activity field:

entryB.lockField(EntryField.ACTIVITY, "arbitrary reason");
System.out.println(entryB.isFieldLocked(EntryField.ACTIVITY));   // true
entryB.setActivity("act_3");   // throws exception

The class LogEntryUtils contains the method lockFieldForEntries which locks a specified field in a list of log entries. Additionally, it contains some convenient methods to retrieve only entries with a particular activity or filtered by their locking status. It is also possible to group log entries according to their activities or cluster originators according to the activities they are responsible for.

The class DULogEntry is a subclass of LogEntry and complements it by a list of data attributes which are affected during the execution of the logged activity (data usage). Each data attribute gets assigned a set of data usage clearances, represented by the enumeration DataUsage. The following code creates a new DULogEntry object and specifies a new data attribute:

DULogEntry entryC = new DULogEntry("act_3");
entryC.setEventType(EventType.start);
entryC.setOriginator("sub_1");
entryC.setRole("r1");
entryC.setTimestamp(new Date(499134120000l));
entryC.addMetaAttribute(new DataAttribute("desc",

    "Marty McFly hits the road to the year 2015."));
entryC.addDataUsage(

    new DataAttribute("fluxcompensatorsettings", settings),
    DataUsage.READ);