Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function loggingOutput(minLevel = "info") {
// returns an array of log messages at or above the prescribed minLevel
return (
log.record
// select all non-empty info, warn, or error logs
.filter(m => log.levels[m.level] >= log.levels[minLevel] && m.message)
// return just the normalized message content
.map(m =>
normalizeNewline(m.message)
.split("\n")
.map(line => line.trimRight())
.join("\n")
)
);
}
function reallyExit() {
// truncate once it's been written.
log.record.length = 0
itWorked = !code
// just emit a fake exit event.
// if we're really exiting, then let it exit on its own, so that
// in-process stuff can finish or clean up first.
if (!doExit) process.emit("exit", code)
}
}
function reallyExit() {
// truncate once it's been written.
log.record.length = 0
itWorked = !code
// just emit a fake exit event.
// if we're really exiting, then let it exit on its own, so that
// in-process stuff can finish or clean up first.
if (!doExit) process.emit("exit", code)
}
}
pref = pref.join(" ");
m.message
.trim()
.split(/\r?\n/)
.map(line => `${pref} ${line}`.trim())
.forEach(line => {
logOutput += line + os.EOL;
});
});
// this must be synchronous because it is called before process exit
writeFileAtomic.sync(path.join(cwd, "lerna-debug.log"), logOutput);
// truncate log after writing
log.record.length = 0;
}
afterEach(() => {
log.record.length = 0;
});
function writeLogFile (cb) {
if (writingLogFile) return cb()
writingLogFile = true
wroteLogFile = true
var fs = require("graceful-fs")
, fstr = fs.createWriteStream("npm-debug.log")
, util = require("util")
, os = require("os")
, out = ""
log.record.forEach(function (m) {
var pref = [m.id, m.level]
if (m.prefix) pref.push(m.prefix)
pref = pref.join(' ')
m.message.trim().split(/\r?\n/).map(function (line) {
return (pref + ' ' + line).trim()
}).forEach(function (line) {
out += line + os.EOL
})
})
fstr.end(out)
fstr.on("close", cb)
}
function writeLogFile (cb) {
if (writingLogFile) return cb()
writingLogFile = true
wroteLogFile = true
var fstr = writeStreamAtomic("npm-debug.log")
, os = require("os")
, out = ""
log.record.forEach(function (m) {
var pref = [m.id, m.level]
if (m.prefix) pref.push(m.prefix)
pref = pref.join(" ")
m.message.trim().split(/\r?\n/).map(function (line) {
return (pref + " " + line).trim()
}).forEach(function (line) {
out += line + os.EOL
})
})
fstr.end(out)
fstr.on("close", cb)
}
function writeLogFile (cb) {
if (writingLogFile) return cb()
writingLogFile = true
wroteLogFile = true
var fs = require("graceful-fs")
, fstr = fs.createWriteStream("npm-debug.log")
, util = require("util")
, os = require("os")
, out = ""
log.record.forEach(function (m) {
var pref = [m.id, m.level]
if (m.prefix) pref.push(m.prefix)
pref = pref.join(' ')
m.message.trim().split(/\r?\n/).map(function (line) {
return (pref + ' ' + line).trim()
}).forEach(function (line) {
out += line + os.EOL
})
})
fstr.end(out)
fstr.on("close", cb)
}
afterEach(() => {
log.record.length = 0;
});
logger.entry('logger.ffdc', opts.clientId);
logger.log('parms', opts.clientId, 'fnc:', opt_fnc);
logger.log('parms', opts.clientId, 'probeId:', opt_probeId);
logger.log('parms', opts.clientId, 'data:', opt_data);
if (npmlog.levels[npmlog.level] <= npmlog.levels.ffdc) {
header('ffdc', opts.clientId, opts);
npmlog.log('ffdc', opts.clientId, new Error().stack);
npmlog.log('ffdc', opts.clientId, '');
npmlog.log('ffdc', opts.clientId, 'Function Stack');
npmlog.log('ffdc', opts.clientId, stack.slice(1));
npmlog.log('ffdc', opts.clientId, '');
npmlog.log('ffdc', opts.clientId, 'Function History');
for (var idx = 0; idx < npmlog.record.length; idx++) {
var rec = npmlog.record[idx];
if ((rec.level !== 'ffdc') &&
(npmlog.levels[rec.level] >= npmlog.levels[historyLevel])) {
npmlog.log('ffdc', opts.clientId, '%d %s %s %s',
rec.id, npmlog.disp[rec.level], rec.prefix, rec.message);
}
}
if (opt_client) {
npmlog.log('ffdc', opts.clientId, '');
npmlog.log('ffdc', opts.clientId, 'Client');
npmlog.log('ffdc', opts.clientId, opt_client);
}
if (opt_data) {
npmlog.log('ffdc', opts.clientId, '');
npmlog.log('ffdc', opts.clientId, 'Data');
npmlog.log('ffdc', opts.clientId, opt_data);
}