electron-log
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -61,2 +61,7 @@ export type ILogLevel = "error" | "warn" | "info" | "verbose" | "debug" | | ||
format: IFormat | string; | ||
/** | ||
* Use styles even if TTY isn't attached | ||
*/ | ||
forceStyles: boolean; | ||
} | ||
@@ -63,0 +68,0 @@ |
@@ -22,2 +22,3 @@ 'use strict'; | ||
transport.level = 'silly'; | ||
transport.forceStyles = Boolean(process.env.FORCE_STYLES); | ||
@@ -37,11 +38,16 @@ if (process.type === 'renderer') { | ||
consoleLog(msg.level, [text].concat(msg.styles)); | ||
} else { | ||
var styles = msg.styles; | ||
return; | ||
} | ||
if (transport.format.substr && transport.format.substr(0, 2) === '%c') { | ||
styles = ['color:' + levelToStyle(msg.level), 'color:unset'] | ||
.concat(styles); | ||
} | ||
var styles = msg.styles; | ||
if (transport.format.substr && transport.format.substr(0, 2) === '%c') { | ||
styles = ['color:' + levelToStyle(msg.level), 'color:unset'] | ||
.concat(styles); | ||
} | ||
if (transport.forceStyles || canUseStyles(msg.level)) { | ||
consoleLog(msg.level, [applyAnsiStyles(text, styles)]); | ||
} else { | ||
consoleLog(msg.level, [text.replace(/%c/g, '')]); | ||
} | ||
@@ -59,2 +65,8 @@ } | ||
function canUseStyles(level) { | ||
var useStderr = level === 'error' || level === 'warn'; | ||
var stream = useStderr ? process.stderr : process.stdout; | ||
return stream && stream.isTTY; | ||
} | ||
function consoleLog(level, args) { | ||
@@ -61,0 +73,0 @@ if (original[level]) { |
{ | ||
"name": "electron-log", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Just a very simple logging module for your Electron application", | ||
@@ -49,3 +49,3 @@ "main": "index.js", | ||
"mocha": "*", | ||
"nw": "0.31", | ||
"nw": "0.36.2", | ||
"tslint": "*", | ||
@@ -52,0 +52,0 @@ "typescript": "*", |
@@ -70,2 +70,4 @@ # electron-log | ||
- **level**, default 'silly' | ||
- **forceStyles**, use styles in the main process even if TTY isn't attached, | ||
default false | ||
@@ -72,0 +74,0 @@ #### File transport |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
37834
1076
167
10