@dxatscale/sfp-logger
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -50,4 +50,5 @@ import chalk = require('chalk'); | ||
static disableLogs(): void; | ||
static printHeaderLine(header: any, color: chalk.Chalk, logLevel: any, logger?: Logger): void; | ||
} | ||
export {}; | ||
//# sourceMappingURL=SFPLogger.d.ts.map |
@@ -83,5 +83,11 @@ "use strict"; | ||
return; | ||
// Split message into lines of 90 characters | ||
const maxLineLength = 120; | ||
const lines = []; | ||
for (let i = 0; i < message.length; i += maxLineLength) { | ||
lines.push(message.substring(i, i + maxLineLength)); | ||
} | ||
//Todo: Proper fix | ||
if (logger && logger.logType === 1 /* LoggerType.console */) { | ||
logger = null; //Make it nullable, so it goes to console | ||
logger = null; // Make it nullable, so it goes to console | ||
} | ||
@@ -94,24 +100,28 @@ if (logger) { | ||
let fileLogger = logger; | ||
message = message === null || message === void 0 ? void 0 : message.toString().replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''); | ||
fs.appendFileSync(fileLogger.path, message + os_1.EOL, 'utf8'); | ||
lines.forEach(line => { | ||
line = line.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''); | ||
fs.appendFileSync(fileLogger.path, line + os_1.EOL, 'utf8'); | ||
}); | ||
} | ||
} | ||
else { | ||
switch (logLevel) { | ||
case LoggerLevel.TRACE: | ||
console.log((0, exports.COLOR_TRACE)(message)); | ||
break; | ||
case LoggerLevel.DEBUG: | ||
console.log((0, exports.COLOR_DEBUG)(message)); | ||
break; | ||
case LoggerLevel.INFO: | ||
console.log(message); | ||
break; | ||
case LoggerLevel.WARN: | ||
console.log((0, exports.COLOR_WARNING)(message)); | ||
break; | ||
case LoggerLevel.ERROR: | ||
console.log((0, exports.COLOR_ERROR)(message)); | ||
break; | ||
} | ||
lines.forEach(line => { | ||
switch (logLevel) { | ||
case LoggerLevel.TRACE: | ||
console.log((0, exports.COLOR_TRACE)(line)); | ||
break; | ||
case LoggerLevel.DEBUG: | ||
console.log((0, exports.COLOR_DEBUG)(line)); | ||
break; | ||
case LoggerLevel.INFO: | ||
console.log(line); | ||
break; | ||
case LoggerLevel.WARN: | ||
console.log((0, exports.COLOR_WARNING)(line)); | ||
break; | ||
case LoggerLevel.ERROR: | ||
console.log((0, exports.COLOR_ERROR)(line)); | ||
break; | ||
} | ||
}); | ||
} | ||
@@ -122,2 +132,22 @@ } | ||
} | ||
static printHeaderLine(header, color, logLevel, logger) { | ||
if (header == null) | ||
header = ''; | ||
const lineLength = 90; | ||
const leftPadLength = Math.floor((lineLength - header.length) / 2); | ||
const rightPadLength = lineLength - leftPadLength - header.length; | ||
const line = '-'.repeat(leftPadLength) + `${header}` + '-'.repeat(rightPadLength); | ||
if (logger) { | ||
if (logger.logType === 3 /* LoggerType.void */) { | ||
return; | ||
} | ||
else if (logger.logType === 2 /* LoggerType.file */) { | ||
return; | ||
} | ||
else | ||
console.log(color(line)); | ||
} | ||
else | ||
console.log(color(line)); | ||
} | ||
} | ||
@@ -127,2 +157,2 @@ SFPLogger.logLevel = LoggerLevel.INFO; | ||
exports.default = SFPLogger; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU0ZQTG9nZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL1NGUExvZ2dlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDZDQUErQjtBQUMvQiwyQkFBeUI7QUFDekIsK0JBQWdDO0FBRWhDLElBQVksV0FRWDtBQVJELFdBQVksV0FBVztJQUNuQixnREFBVSxDQUFBO0lBQ1YsZ0RBQVUsQ0FBQTtJQUNWLDhDQUFTLENBQUE7SUFDVCw4Q0FBUyxDQUFBO0lBQ1QsZ0RBQ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FNLGNBQWMsR0FBRyxVQUFVLEdBQUcsYUFBYSxHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUM7UUFDbEUsTUFBTSxJQUFJLEdBQUcsR0FBRyxDQUFDLE1BQU0sQ0FBQyxhQUFhLENBQUMsR0FBRyxHQUFHLE1BQU0sRUFBRSxHQUFHLEdBQUcsQ0FBQyxNQUFNLENBQUMsY0FBYyxDQUFDLENBQUM7UUFDbEYsSUFBSSxNQUFNLEVBQUU7WUFDVixJQUFJLE1BQU0sQ0FBQyxPQUFPLDRCQUFvQixFQUFFO2dCQUN0QyxPQUFPO2FBQ1I7aUJBQU0sSUFBSSxNQUFNLENBQUMsT0FBTyw0QkFBb0IsRUFBRTtnQkFDN0MsT0FBTzthQUNSOztnQkFFQyxPQUFPLENBQUMsR0FBRyxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO1NBQzVCOztZQUVDLE9BQU8sQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7SUFFN0IsQ0FBQzs7QUF6RmEsa0JBQVEsR0FBZ0IsV0FBVyxDQUFDLElBQUksQ0FBQztBQUN6Qyx3QkFBYyxHQUFZLEtBQUssQ0FBQztrQkFGM0IsU0FBUyJ9 |
{ | ||
"name": "@dxatscale/sfp-logger", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "sfp logger library", | ||
@@ -41,3 +41,3 @@ "main": "lib/SFPLogger.js", | ||
], | ||
"gitHead": "d2ef9efbbb247fd60adbffcd54cb91ff2a566659" | ||
"gitHead": "db6d58a3476e87930b589a76a86bd7b59b3958a9" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15917
206