How to use the caterpillar.Logger function in caterpillar

To help you get started, we’ve selected a few caterpillar 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 bevry / projectz / source / bin.js View on Github external
const cli = require('commander')

// Import our package data for versioning
const { version } = require('../package.json')

// Import out projectz utility
const { Projectz } = require('./index.js')

// Prepare our logging configuration
const LOG_LEVEL_INFO = 6
const LOG_LEVEL_DEBUG = 7
const EXIT_ERROR_CODE = 1
const level = process.argv.includes('-d') ? LOG_LEVEL_DEBUG : LOG_LEVEL_INFO

// Setup our logging
const logger = new Logger({ level })
const filter = new Filter()
const human = new Human()

// Pipe logger output to filter, then filter output to stdout
logger
	.pipe(filter)
	.pipe(human)
	.pipe(process.stdout)

// Extract out version out of our package and apply it to commander
cli.version(version)

// Define usage information
cli.usage(' [options]')

// Add our cwd customisation
github krohrsb / Bookworm / src / services / log / log.js View on Github external
LogService.prototype.initialize = function () {
    "use strict";
    var logFilter, logHuman;

    logHuman = human.createHuman();
    //create the logger
    this._logger = new Logger(this._settings.config);

    if (this._settings.loggers.console.enabled) {
        logFilter = filter.createFilter({level: (this._settings.loggers.console.debug ? 7 : 6)});
        this._logger.pipe(logFilter).pipe(logHuman).pipe(process.stdout);
    }

    if (this._settings.loggers.file.enabled) {

        if (!fs.existsSync(path.dirname(this._settings.loggers.file.filename))) {
            fs.mkdirSync(path.dirname(this._settings.loggers.file.filename));
        }

        logFilter = filter.createFilter({level: (this._settings.loggers.file.debug ? 7 : 6)});
        this._logger.pipe(logFilter).pipe(es.join('\n')).pipe(fs.createWriteStream(this._settings.loggers.file.filename, {flags: 'a'}));
    }
};
github lorenwest / node-monitor / node_modules / docpad / out / lib / docpad.js View on Github external
if (err && docpad.getDebugging()) {
        locale = docpad.getLocale();
        return docpad.log('warn', locale.reportError + ' ' + locale.errorFollows, ((_ref2 = err.stack) != null ? _ref2 : err.message).toString());
      }
    });
    this.trackRunnerInstance = new TaskGroup().run().on('complete', function(err) {
      var locale, _ref2;
      if (err && docpad.getDebugging()) {
        locale = docpad.getLocale();
        return docpad.log('warn', locale.trackError + ' ' + locale.errorFollows, ((_ref2 = err.stack) != null ? _ref2 : err.message).toString());
      }
    });
    if ((loggers = instanceConfig.loggers)) {
      delete instanceConfig.loggers;
    } else {
      logger = new (require('caterpillar').Logger)({
        lineOffset: 2
      });
      loggerConsole = logger.pipe(new (require('caterpillar-filter').Filter)).pipe(new (require('caterpillar-human').Human));
      loggers = {
        logger: logger,
        console: loggerConsole
      };
    }
    safefs.unlink(this.debugLogPath, function() {});
    this.setLoggers(loggers);
    this.setLogLevel(this.initialConfig.logLevel);
    this.on('log', function() {
      var args;
      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
      return docpad.log.apply(this, args);
    });
github nfriedly / nfriedly.com / node_modules / docpad / out / lib / docpad.js View on Github external
if (err && docpad.getDebugging()) {
        locale = docpad.getLocale();
        return docpad.log('warn', locale.reportError + ' ' + locale.errorFollows, ((_ref2 = err.stack) != null ? _ref2 : err.message).toString());
      }
    });
    this.trackRunnerInstance = new TaskGroup().run().on('complete', function(err) {
      var locale, _ref2;
      if (err && docpad.getDebugging()) {
        locale = docpad.getLocale();
        return docpad.log('warn', locale.trackError + ' ' + locale.errorFollows, ((_ref2 = err.stack) != null ? _ref2 : err.message).toString());
      }
    });
    if ((loggers = instanceConfig.loggers)) {
      delete instanceConfig.loggers;
    } else {
      logger = new (require('caterpillar').Logger)({
        lineOffset: 2
      });
      loggerConsole = logger.pipe(new (require('caterpillar-filter').Filter)).pipe(new (require('caterpillar-human').Human));
      loggers = {
        logger: logger,
        console: loggerConsole
      };
    }
    safefs.unlink(this.debugLogPath, function() {});
    this.setLoggers(loggers);
    this.setLogLevel(this.initialConfig.logLevel);
    this.on('log', function() {
      var args;
      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
      return docpad.log.apply(this, args);
    });

caterpillar

Caterpillar is the ultimate logging system for Deno, Node.js, and Web Browsers. Log levels are implemented to the RFC standard. Log entries can be filtered and piped to various streams, including coloured output to the terminal, the browser's console, and

Artistic-2.0
Latest version published 12 months ago

Package Health Score

66 / 100
Full package analysis