@fastkit/tiny-logger
Advanced tools
Comparing version 0.1.15 to 0.1.16
@@ -5,2 +5,4 @@ 'use strict'; | ||
var helpers = require('@fastkit/helpers'); | ||
const TINY_LOGGER_LOG_TYPES = [ | ||
@@ -13,25 +15,12 @@ 'debug', | ||
]; | ||
const PALETTE = { | ||
reset: '\u001b[0m', | ||
// black: '\u001b[30m', | ||
red: '\u001b[31m', | ||
green: '\u001b[32m', | ||
yellow: '\u001b[33m', | ||
// blue: '\u001b[34m', | ||
magenta: '\u001b[35m', | ||
cyan: '\u001b[36m', | ||
// white: '\u001b[37m' | ||
}; | ||
const COLOR_MAP = { | ||
debug: PALETTE.magenta, | ||
info: PALETTE.cyan, | ||
warn: PALETTE.yellow, | ||
error: PALETTE.red, | ||
success: PALETTE.green, | ||
debug: 'magenta', | ||
info: 'cyan', | ||
warn: 'yellow', | ||
error: 'red', | ||
success: 'green', | ||
}; | ||
let colorEnable = true; | ||
class TinyLogger { | ||
constructor(loggerName) { | ||
this._name = loggerName; | ||
} | ||
_name; | ||
static colorEnable(enable) { | ||
@@ -43,7 +32,10 @@ colorEnable = enable; | ||
} | ||
constructor(loggerName) { | ||
this._name = loggerName; | ||
} | ||
log(type, message, ...args) { | ||
const colorOpenTag = (colorEnable && COLOR_MAP[type]) || ''; | ||
const colorCloseTag = colorOpenTag ? PALETTE.reset : ''; | ||
const color = colorEnable && COLOR_MAP[type]; | ||
const body = color ? helpers.consoleColorString(message, color) : message; | ||
const fn = type === 'success' ? 'log' : type; | ||
console[fn](`${colorOpenTag}[${this.name}] ${message}${colorCloseTag}`, ...args); | ||
console[fn](body, ...args); | ||
} | ||
@@ -50,0 +42,0 @@ } |
@@ -5,2 +5,4 @@ 'use strict'; | ||
var helpers = require('@fastkit/helpers'); | ||
const TINY_LOGGER_LOG_TYPES = [ | ||
@@ -13,25 +15,12 @@ 'debug', | ||
]; | ||
const PALETTE = { | ||
reset: '\u001b[0m', | ||
// black: '\u001b[30m', | ||
red: '\u001b[31m', | ||
green: '\u001b[32m', | ||
yellow: '\u001b[33m', | ||
// blue: '\u001b[34m', | ||
magenta: '\u001b[35m', | ||
cyan: '\u001b[36m', | ||
// white: '\u001b[37m' | ||
}; | ||
const COLOR_MAP = { | ||
debug: PALETTE.magenta, | ||
info: PALETTE.cyan, | ||
warn: PALETTE.yellow, | ||
error: PALETTE.red, | ||
success: PALETTE.green, | ||
debug: 'magenta', | ||
info: 'cyan', | ||
warn: 'yellow', | ||
error: 'red', | ||
success: 'green', | ||
}; | ||
let colorEnable = true; | ||
class TinyLogger { | ||
constructor(loggerName) { | ||
this._name = loggerName; | ||
} | ||
_name; | ||
static colorEnable(enable) { | ||
@@ -43,7 +32,10 @@ colorEnable = enable; | ||
} | ||
constructor(loggerName) { | ||
this._name = loggerName; | ||
} | ||
log(type, message, ...args) { | ||
const colorOpenTag = (colorEnable && COLOR_MAP[type]) || ''; | ||
const colorCloseTag = colorOpenTag ? PALETTE.reset : ''; | ||
const color = colorEnable && COLOR_MAP[type]; | ||
const body = color ? helpers.consoleColorString(message, color) : message; | ||
const fn = type === 'success' ? 'log' : type; | ||
console[fn](`${colorOpenTag}[${this.name}] ${message}${colorCloseTag}`, ...args); | ||
console[fn](body, ...args); | ||
} | ||
@@ -50,0 +42,0 @@ } |
/// <reference types="node" /> | ||
import { ConsoleColorPaletteName } from '@fastkit/helpers'; | ||
export declare const COLOR_MAP: { | ||
[K in TinyLoggerLogType]?: string; | ||
[K in TinyLoggerLogType]?: ConsoleColorPaletteName; | ||
}; | ||
@@ -6,0 +8,0 @@ |
@@ -0,1 +1,3 @@ | ||
import { consoleColorString } from '@fastkit/helpers'; | ||
const TINY_LOGGER_LOG_TYPES = [ | ||
@@ -8,25 +10,12 @@ 'debug', | ||
]; | ||
const PALETTE = { | ||
reset: '\u001b[0m', | ||
// black: '\u001b[30m', | ||
red: '\u001b[31m', | ||
green: '\u001b[32m', | ||
yellow: '\u001b[33m', | ||
// blue: '\u001b[34m', | ||
magenta: '\u001b[35m', | ||
cyan: '\u001b[36m', | ||
// white: '\u001b[37m' | ||
}; | ||
const COLOR_MAP = { | ||
debug: PALETTE.magenta, | ||
info: PALETTE.cyan, | ||
warn: PALETTE.yellow, | ||
error: PALETTE.red, | ||
success: PALETTE.green, | ||
debug: 'magenta', | ||
info: 'cyan', | ||
warn: 'yellow', | ||
error: 'red', | ||
success: 'green', | ||
}; | ||
let colorEnable = true; | ||
class TinyLogger { | ||
constructor(loggerName) { | ||
this._name = loggerName; | ||
} | ||
_name; | ||
static colorEnable(enable) { | ||
@@ -38,7 +27,10 @@ colorEnable = enable; | ||
} | ||
constructor(loggerName) { | ||
this._name = loggerName; | ||
} | ||
log(type, message, ...args) { | ||
const colorOpenTag = (colorEnable && COLOR_MAP[type]) || ''; | ||
const colorCloseTag = colorOpenTag ? PALETTE.reset : ''; | ||
const color = colorEnable && COLOR_MAP[type]; | ||
const body = color ? consoleColorString(message, color) : message; | ||
const fn = type === 'success' ? 'log' : type; | ||
console[fn](`${colorOpenTag}[${this.name}] ${message}${colorCloseTag}`, ...args); | ||
console[fn](body, ...args); | ||
} | ||
@@ -45,0 +37,0 @@ } |
{ | ||
"name": "@fastkit/tiny-logger", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"description": "@fastkit/tiny-logger", | ||
@@ -27,3 +27,6 @@ "buildOptions": { | ||
}, | ||
"homepage": "https://github.com/dadajam4/fastkit/tree/dev/packages/tiny-logger#readme" | ||
"homepage": "https://github.com/dadajam4/fastkit/tree/dev/packages/tiny-logger#readme", | ||
"dependencies": { | ||
"@fastkit/helpers": "0.1.16" | ||
} | ||
} |
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
7611
1
227
+ Added@fastkit/helpers@0.1.16
+ Added@fastkit/helpers@0.1.16(transitive)