HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/zaklada/html/node_modules/winston/test/transports/file-maxsize-test.js
/*
 * file-test.js: Tests for instances of the File transport
 *
 * (C) 2010 Charlie Robbins
 * MIT LICENSE
 *
 */

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

var maxsizeTransport = new winston.transports.File({
  timestamp: false,
  json: false,
  filename: path.join(__dirname, '..', 'fixtures', 'logs', 'testmaxsize.log'),
  maxsize: 4096
});
    
vows.describe('winston/transports/file/maxsize').addBatch({
  "An instance of the File Transport": {
    "when passed a valid filename": {
      "the log() method": {
        topic: function () {
          exec('rm -rf ' + path.join(__dirname, '..', 'fixtures', 'logs', 'testmaxsize*'), this.callback);
        },
        "when passed more than the maxsize": {
          topic: function () {
            var that = this,
                data = new Array(1018).join('-');
            
            //
            // Setup a list of files which we will later stat.
            //
            that.files = [];
            
            function logKbytes (kbytes) {
              //
              // With no timestamp and at the info level,
              // winston adds exactly 7 characters: 
              // [info](4)[ :](2)[\n](1)
              //
              for (var i = 0; i < kbytes; i++) {
                maxsizeTransport.log('info', data, null, function () { });
              }
            }
            
            maxsizeTransport.on('open', function (file) {
              var match = file.match(/(\d+)\.log$/),
                  count = match ? match[1] : 0;
              
              that.files.push(file);
              
              if (that.files.length === 5) {
                return that.callback();
              }
              
              logKbytes(4);
            });
            
            logKbytes(4);
          },
          "should create multiple files correctly": function () {
            this.files.forEach(function (file) {
              try {
                var stats = fs.statSync(file);
                assert.equal(stats.size, 4096);
              }
              catch (ex) {
                assert.isNull(ex);
              }
            });
          }
        }
      }
    }
  }
}).export(module);