HEX
Server: Apache
System: Linux server.instantlogomakers.com 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: s2spw (1156)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/node_modules/forever/node_modules/broadway/node_modules/winston/test/log-exception-test.js
/*
 * exception-test.js: Tests for exception data gathering in winston.
 *
 * (C) 2010 Charlie Robbins
 * MIT LICENSE
 *
 */

var assert = require('assert'),
    path = require('path'),
    fs = require('fs'),
    spawn = require('child_process').spawn,
    vows = require('vows'),
    winston = require('../lib/winston'),
    helpers = require('./helpers'),
    exists = (fs.exists || path.exists);

vows.describe('winston/logger/exceptions').addBatch({
  "When using winston": {
    "the handleException() method": {
      "with a custom winston.Logger instance": helpers.assertHandleExceptions({
        script: path.join(__dirname, 'fixtures', 'scripts', 'log-exceptions.js'),
        logfile: path.join(__dirname, 'fixtures', 'logs', 'exception.log')
      }),
      "with the default winston logger": helpers.assertHandleExceptions({
        script: path.join(__dirname, 'fixtures', 'scripts', 'default-exceptions.js'),
        logfile: path.join(__dirname, 'fixtures', 'logs', 'default-exception.log')
      }),
      "when a custom exitOnError function is set": {
        topic: function () {
          var that = this,
              scriptDir = path.join(__dirname, 'fixtures', 'scripts');
          
          that.child = spawn('node', [path.join(scriptDir, 'exit-on-error.js')]);
          setTimeout(this.callback.bind(this), 1500);
        },
        "should not exit the process": function () {
          assert.isFalse(this.child.killed);
          this.child.kill();
        }
      }
    },
    "the unhandleException() method": {
      topic: function () {
        var that = this,
            child = spawn('node', [path.join(__dirname, 'fixtures', 'scripts', 'unhandle-exceptions.js')]),
            exception = path.join(__dirname, 'fixtures', 'logs', 'unhandle-exception.log');
        
        helpers.tryUnlink(exception);
        child.on('exit', function () {
          exists(exception, that.callback.bind(this, null));
        });
      },
      "should not write to the specified error file": function (err, exists) {
        assert.isTrue(!err);
        assert.isFalse(exists);
      }
    }
  }
}).export(module);