How to use simple-node-logger - 10 common examples

To help you get started, we’ve selected a few simple-node-logger 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 Ash-sc / online-reader / server / article / article.js View on Github external
const SimpleNodeLogger = require('simple-node-logger');
const moment = require('moment');
const cheerio = require('cheerio');
const charset = require('superagent-charset');
const request = require('superagent');
const fs = require('fs');
const urlencode = require('urlencode');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;

charset(request);
const opts = {
  logFilePath: `logs/article-log-${moment().format('YYYY-MM-DD')}.log`,
  timestampFormat: 'YYYY-MM-DD HH:mm:ss',
};
const log = SimpleNodeLogger.createSimpleLogger(opts);

// 获取小说内容并打包成txt文件
const getContent = (index, charterList, articleUrl, articleName) => {
  log.info(`get charter ${charterList[index].title} content ...`);
  request.get(articleUrl + charterList[index].href)
    .charset('gbk')
    .end((error, resp) => {
      if (error) {
        log.error(`get charter ${charterList[index].title} error : `, error);
      } else {
        log.info(`get charter ${charterList[index].title} success !`);
        const $ = cheerio.load(resp.text);
        const content = charterList[index].title + '\n' + unescape($($('#BookText')[0]).html()
            .replace(/&#x/g, '%u')
            .replace(/;/g, '')
            .replace(/%uA0/g, ' ')
github widdix / aws-cf-templates-cli / lib / log.js View on Github external
'use strict';

const log = require('simple-node-logger').createSimpleFileLogger('widdix.log'); // TODO replace with something that can be flushed finally
const serializeError = require('serialize-error');

const wrapper = (level) => {
  return (message, data) => {
    if (data !== undefined) {
      if (data instanceof Error) {
        log[level](message, serializeError(data));
      } else {
        log[level](message, JSON.stringify(data));
      }
    } else {
      log[level](message);
    }
  };
};
github darrylwest / mock-browser / test / MockBrowserTests.js View on Github external
/**
 * @class MockBrowserTests
 *
 * @author: darryl.west@roundpeg.com
 * @created: 10/10/14 5:02 PM
 */
var should = require('chai').should(),
    dash = require('lodash' ),
    MockLogger = require('simple-node-logger' ).mocks.MockLogger,
    MockBrowser = require('../lib/MockBrowser');

describe('MockBrowser', function() {
    'use strict';

    describe('#instance', function() {
        var browser = new MockBrowser(),
            methods = [
                'getDocument',
                'getWindow',
                'getHistory',
                'getLocation',
                'getNavigator',
                'getLocalStorage',
                'getSessionStorage'
            ];
github darrylwest / mock-browser / test / AbstractBrowserTests.js View on Github external
/**
 * @class AbstractBrowserTests
 *
 * @author: darryl.west@roundpeg.com
 * @created: 10/10/14 9:32 AM
 */
var should = require('chai').should(),
    dash = require('lodash' ),
    jsdom = require('jsdom' ).jsdom,
    MockLogger = require('simple-node-logger' ).mocks.MockLogger,
    MockStorage = require('../lib/MockStorage' ),
    AbstractBrowser = require('../lib/AbstractBrowser');

describe('AbstractBrowser', function() {
    'use strict';

    var createOptions = function() {
        var opts = {},
            doc = jsdom('<div>' ),
            win = doc.defaultView;

        opts.window = win;
        opts.localStorage = new MockStorage();
        opts.sessionStorage = new MockStorage();

        return opts;</div>
github darrylwest / mock-browser / test / MockStorageTests.js View on Github external
/**
 * @class AbstractStorageTests
 *
 * @author: darryl.west@roundpeg.com
 * @created: 10/10/14 4:12 PM
 */
var should = require('chai').should(),
    dash = require('lodash' ),
    MockLogger = require('simple-node-logger' ).mocks.MockLogger,
    MockStorage = require('../lib/MockStorage');

describe('MockStorage', function() {
    'use strict';

    describe('#instance', function() {
        var storage = new MockStorage(),
            methods = [
                'getItem',
                'setItem',
                'clear',
                'key',
                '__protected'
            ];

        it('should create an instance of MockStorage', function() {
github ibi-group / datatools-ui / __tests__ / end-to-end.js View on Github external
code: '2',
  description: 'test 2',
  id: 'test-stop-2',
  lat: '37.04783038',
  lon: '-122.07521176',
  name: 'Russell Ave and Valley Dr',
  url: 'example.stop/2'
}
let testProjectId
let feedSourceId
let scratchFeedSourceId
let routerId
const log = SimpleNodeLogger.createSimpleFileLogger(
  getTestFolderFilename(`e2e-run-${fileSafeTestTime}.log`)
)
const browserEventLogs = SimpleNodeLogger.createSimpleFileLogger(
  getTestFolderFilename(`e2e-run-${fileSafeTestTime}-browser-events.log`)
)
const testResults = {}
const defaultTestTimeout = 100000
const defaultJobTimeout = 100000

function makeMakeTest (defaultDependentTests: Array | string = []) {
  if (!(defaultDependentTests instanceof Array)) {
    defaultDependentTests = [defaultDependentTests]
  }
  return (
    name: string,
    fn: Function,
    timeout?: number,
    dependentTests: Array | string = []
  ) =&gt; {
github ibi-group / datatools-ui / __tests__ / end-to-end.js View on Github external
url: 'example.stop/1'
}
const dummyStop2 = {
  code: '2',
  description: 'test 2',
  id: 'test-stop-2',
  lat: '37.04783038',
  lon: '-122.07521176',
  name: 'Russell Ave and Valley Dr',
  url: 'example.stop/2'
}
let testProjectId
let feedSourceId
let scratchFeedSourceId
let routerId
const log = SimpleNodeLogger.createSimpleFileLogger(
  getTestFolderFilename(`e2e-run-${fileSafeTestTime}.log`)
)
const browserEventLogs = SimpleNodeLogger.createSimpleFileLogger(
  getTestFolderFilename(`e2e-run-${fileSafeTestTime}-browser-events.log`)
)
const testResults = {}
const defaultTestTimeout = 100000
const defaultJobTimeout = 100000

function makeMakeTest (defaultDependentTests: Array | string = []) {
  if (!(defaultDependentTests instanceof Array)) {
    defaultDependentTests = [defaultDependentTests]
  }
  return (
    name: string,
    fn: Function,
github evoluteur / evolutility-server-node / js / utils / logger.js View on Github external
*/

const config = require('../../config.js'),
	pkg = require('../../package.json'),
	chalk = require('chalk'),
	_ = require('underscore'),
	fileLog = config.logToFile,
	consoleLog = config.logToConsole;
let log = {}
if(fileLog){
	const SimpleNodeLogger = require('simple-node-logger'),
		opts = {
			logFilePath:'evol-'+(new Date()).toISOString().substring(0, 10)+'.log',
			timestampFormat:'YYYY-MM-DD HH:mm:ss.SSS'
		}
	log = SimpleNodeLogger.createSimpleLogger( opts );
}


const asciiArt = 
`  ______          _           _ _ _
 |  ____|        | |      /| (_) (_)/|
 | |____   _____ | |_   _| |_ _| |_| |_ _   _
 |  __\\ \\ / / _ \\| | | | | __| | | | __| | | |
 | |___\\ V / (_) | | |_| | |_| | | | |_| |_| |
 |______\\_/ \\___/|_|\\__,_|\\__|_|_|_|\\__|\\__, |
         ___  ___ _ ____   _____ _ __    __/ |
  ____  / __|/ _ \\ \'__\\ \\ / / _ \\ \'__|  |___/
 |____| \\__ \\  __/ |   \\ V /  __/ |
        |___/\\___|_|    \\_/ \\___|_|    v`+pkg.version

function green(msg){
github glenndehaan / csgo-matchmaking / server / modules / logger.js View on Github external
/**
 * Import base packages
 */
const log = require('simple-node-logger').createSimpleLogger('./csgo-matchmaking.log');
const config = require("../config/config");

/**
 * Set log level from config
 */
log.setLevel(config.application.logLevel);

module.exports = log;
github jasonpolites / gcf-recipes / emulator / server.js View on Github external
var util = require('util')
var express = require('express');
var bodyParser = require('body-parser');
const path = require('path');
var log = require('simple-node-logger').createSimpleLogger('emulator.log');
var port = process.argv[2];
var app = express();
var jsonfile = require('jsonfile');
var fs = require('fs');

var server;
var DEPLOYED_FUNCTIONS_FILE = './functions.json';

app.use(logErrors);
app.use(bodyParser.json());
app.use(bodyParser.raw());
app.use(bodyParser.text());
app.use(bodyParser.urlencoded({
  extended: true
}));

simple-node-logger

A node console and file logger suitable for small, medium and large production projects.

Apache-2.0
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis