This file is indexed.

/usr/lib/nodejs/log4js/appenders/hookio.js is in node-log4js 0.6.9-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"use strict";
var log4js = require('../log4js')
, layouts = require('../layouts')
, Hook = require('hook.io').Hook
, util = require('util');

var Logger = function createLogger(options) {
  var self = this;
  var actualAppender = options.actualAppender;
  Hook.call(self, options);
  self.on('hook::ready', function hookReady() {
    self.on('*::' + options.name + '::log', function log(loggingEvent) {
      deserializeLoggingEvent(loggingEvent);
      actualAppender(loggingEvent);
    });
  });
};
util.inherits(Logger, Hook);

function deserializeLoggingEvent(loggingEvent) {
  loggingEvent.startTime = new Date(loggingEvent.startTime);
  loggingEvent.level.toString = function levelToString() {
    return loggingEvent.level.levelStr;
  };
}

function initHook(hookioOptions) {
  var loggerHook;
  if (hookioOptions.mode === 'master') {
    // Start the master hook, handling the actual logging
    loggerHook = new Logger(hookioOptions);
  } else {
    // Start a worker, just emitting events for a master
    loggerHook = new Hook(hookioOptions);
  }
  loggerHook.start();
  return loggerHook;
}

function getBufferedHook(hook, eventName) {
  var hookBuffer = [];
  var hookReady = false;
  hook.on('hook::ready', function emptyBuffer() {
    hookBuffer.forEach(function logBufferItem(loggingEvent) {
      hook.emit(eventName, loggingEvent);
    });
    hookReady = true;
  });

  return function log(loggingEvent) {
    if (hookReady) {
      hook.emit(eventName, loggingEvent);
    } else {
      hookBuffer.push(loggingEvent);
    }
  };
}

function createAppender(hookioOptions) {
  var loggerHook = initHook(hookioOptions);
  var loggerEvent = hookioOptions.name + '::log';
  return getBufferedHook(loggerHook, loggerEvent);
}

function configure(config) {
  var actualAppender;
  if (config.appender && config.mode === 'master') {
    log4js.loadAppender(config.appender.type);
    actualAppender = log4js.appenderMakers[config.appender.type](config.appender);
    config.actualAppender = actualAppender;
  }
  return createAppender(config);
}

exports.appender = createAppender;
exports.configure = configure;