Skip to content

Method chaining and default flush when stopTimer() is called. #3

@lewisdavidcole

Description

@lewisdavidcole

I am combining 2 small enhancement requests here:

  1. Modify the return types where possible on LogEntry to return a reference to itself and allow method chaining.
  2. Accept a second parameter (overloaded method) on the LogEntry.stoptimer() method to allow the flush to happen instantly: LogEntry(String timerName, boolean flush).

The results would look similar to the following (my code is in groovy):

BEFORE
private def processEvent(def event)
{
    LogEntry logEntry = new LogEntry();
    logEntry.startTimer("processEvent");
    logEntry.addField("event", event);
    Thread.sleep(10000);
    logEntry.stopTimer("processEvent");
    logEntry.flush();
}

AFTER
private def processEvent(def event)
{
    LogEntry logEntry = new LogEntry().addField("event", event).startTimer("processEvent");
    Thread.sleep(10000);
    logEntry.stopTimer("processEvent", true);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions