How to use the utility.logDate function in utility

To help you get started, we’ve selected a few utility examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eggjs / egg-logger / lib / transports / file.js View on Github external
const onError = err => {
      console.error('%s ERROR %s [egg-logger] [%s] %s',
        utility.logDate(','), process.pid, this.options.file, err.stack);
      this.reload();
      console.warn('%s WARN %s [egg-logger] [%s] reloaded', utility.logDate(','), process.pid, this.options.file);
    };
    // only listen error once because stream will reload after error
github TaleLin / lin-cms-koa-core / lib / logger / file.ts View on Github external
const onError = err => {
      console.error(
        '%s ERROR %s [logger] [%s] %s',
        utility.logDate(','),
        process.pid,
        filename,
        err.stack
      );
      this.reload();
      console.warn(
        '%s WARN %s [logger] [%s] reloaded',
        utility.logDate(','),
        process.pid,
        filename
      );
    };
    // only listen error once because stream will reload after error
github eggjs / egg-logger / benchmark / format_buffer_vs_string.js View on Github external
meta = meta || {};
  let message;
  let output;
  const formatter = meta.formatter || options.formatter;

  if (args[0] instanceof Error) {
    message = formatError(args[0]);
  } else {
    message = util.format.apply(util, args);
  }

  if (meta.raw === true) {
    output = message;
  } else if (options.json === true || formatter) {
    meta.level = level;
    meta.date = utility.logDate(',');
    meta.pid = process.pid;
    meta.hostname = hostname;
    meta.message = message;
    output = options.json === true ? JSON.stringify(meta) : formatter(meta);
  } else {
    output = message;
  }

  if (!output) return new Buffer('');

  output += options.eol;

  // convert string to buffer when encoding is not utf8
  return options.encoding === 'utf8' ? new Buffer(output) : iconv.encode(output, options.encoding);
}
github eggjs / egg-logger / lib / utils.js View on Github external
let message;
    let output;
    let formatter = meta.formatter || options.formatter;
    if (meta.ctx && options.contextFormatter) formatter = options.contextFormatter;

    if (args[0] instanceof Error) {
      message = formatError(args[0]);
    } else {
      message = util.format.apply(util, args);
    }

    if (meta.raw === true) {
      output = message;
    } else if (options.json === true || formatter) {
      meta.level = level;
      meta.date = utility.logDate(',');
      meta.pid = process.pid;
      meta.hostname = hostname;
      meta.message = message;
      output = options.json === true ? JSON.stringify(meta) : formatter(meta);
    } else {
      output = message;
    }

    if (!output) return new Buffer('');

    output += options.eol;

    // convert string to buffer when encoding is not utf8
    return options.encoding === 'utf8' ? output : iconv.encode(output, options.encoding);
  },
github node-modules / cfork / index.js View on Github external
function onReachReforkLimit() {
    console.error('[%s] [cfork:master:%s] worker died too fast (total %d disconnect, %d unexpected exit)',
      utility.logDate(), process.pid, disconnectCount, unexpectedCount);
  }
github node-modules / cfork / index.js View on Github external
function onUnexpected(worker, code, signal) {
    var exitCode = worker.process.exitCode;
    var propertyName = worker.hasOwnProperty('exitedAfterDisconnect') ? 'exitedAfterDisconnect' : 'suicide';
    var err = new Error(util.format('worker:%s died unexpected (code: %s, signal: %s, %s: %s, state: %s)',
      worker.process.pid, exitCode, signal, propertyName, worker[propertyName], worker.state));
    err.name = 'WorkerDiedUnexpectedError';

    console.error('[%s] [cfork:master:%s] (total %d disconnect, %d unexpected exit) %s',
      utility.logDate(), process.pid, disconnectCount, unexpectedCount, err.stack);
  }
github linzhixian / quick-vue-admin / src / server / db / BaseDb3.js View on Github external
function log(str) {
    console.error(utility.logDate() + ":" + str);
}
github linzhixian / quick-vue-admin / src / server / db / BaseDb.js View on Github external
this.open(function(aconn) {
            log("connected to:" + parent.dburl);
            parent.conn = aconn;
            aconn.collection("connStatus").updateOne({ _id: parent.serverid }, {
                $set: {
                    addTime: utility.logDate(),
                    updateTime: utility.logDate(),
                    count: 1
                }
            }, { upsert: true }, function(err, r) {
                if (!err) {
                    parent.startConnCheck();
                }
            });
            parent.ready();
        });