Add support for including process PID in the layout / multiprocess #143

Open
nickminutello opened this Issue Jul 15, 2013 · 0 comments

Projects

None yet

1 participant

@nickminutello

It requires:

  1. A pattern so the pid can be defined in the layout format
  2. multi-process has to add the pid to the logging event before sending it.

Change to multiprocess.js:

    function write(loggingEvent) {
        loggingEvent.pid = process.pid; // add PID
        socket.write(JSON.stringify(loggingEvent), 'utf8');
        socket.write(END_MSG, 'utf8');
    }

Change to layouts.js:

function timestampLevelAndCategory(loggingEvent, colour) {
    var output = colorize(
        formatLogData(
            '[PID %s] [%s] [%s] %s - '
          , loggingEvent.pid || process.pid // If its a remote logging event, want to use the pid from the event.
          , dateFormat.asString(loggingEvent.startTime)
          , loggingEvent.level
          , loggingEvent.categoryName
        )
      , colour
    );
    return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment