@icon-magic/logger
Advanced tools
Comparing version 2.0.1-beta.0 to 2.2.8-beta.0
@@ -9,11 +9,23 @@ import * as winston from 'winston'; | ||
*/ | ||
export interface Logger { | ||
error: (msg: string) => void; | ||
debug: (msg: string) => void; | ||
info: (msg: string) => void; | ||
interface LoggerInterface { | ||
error(msg: string): void; | ||
debug(msg: string): void; | ||
info(msg: string): void; | ||
setDebug(debug: boolean): void; | ||
} | ||
/** | ||
* Wrapper around winston's logger that takes in a fileName | ||
* @const debugState <boolean> defaults to false, passed in from cli flags. | ||
* Using commander, -d or --debug flag will make this true. | ||
* @param fileName name of the file that's added as a label to the logging data | ||
*/ | ||
export declare function logger(fileName: string): Logger; | ||
export declare class Logger implements LoggerInterface { | ||
fileName: string; | ||
static debugState: boolean; | ||
constructor(fileName: string); | ||
error(msg?: string): void; | ||
debug(msg?: string): void; | ||
info(msg: string): void; | ||
setDebug(debug: boolean): void; | ||
} | ||
export {}; |
@@ -21,18 +21,27 @@ "use strict"; | ||
* Wrapper around winston's logger that takes in a fileName | ||
* @const debugState <boolean> defaults to false, passed in from cli flags. | ||
* Using commander, -d or --debug flag will make this true. | ||
* @param fileName name of the file that's added as a label to the logging data | ||
*/ | ||
function logger(fileName) { | ||
return { | ||
error: function (msg) { | ||
exports.winstonLogger.error({ message: msg, label: fileName }); | ||
}, | ||
debug: function (msg) { | ||
exports.winstonLogger.debug({ message: msg, label: fileName }); | ||
}, | ||
info: function (msg) { | ||
exports.winstonLogger.info({ message: msg, label: fileName }); | ||
class Logger { | ||
constructor(fileName) { | ||
this.fileName = fileName; | ||
} | ||
error(msg = '') { | ||
exports.winstonLogger.error({ message: msg, label: this.fileName }); | ||
} | ||
debug(msg = '') { | ||
if (Logger.debugState) { | ||
exports.winstonLogger.debug({ message: msg, label: this.fileName }); | ||
} | ||
}; | ||
} | ||
info(msg) { | ||
exports.winstonLogger.info({ message: msg, label: this.fileName }); | ||
} | ||
setDebug(debug) { | ||
Logger.debugState = debug; | ||
} | ||
} | ||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U6IG1zZywgbGFiZWw6IHRoaXMuZmlsZU5hbWUgfSk7XG4gIH1cbiAgZGVidWcobXNnOiBzdHJpbmcgPSAnJyk6IHZvaWQge1xuICAgIGlmIChMb2dnZXIuZGVidWdTdGF0ZSkge1xuICAgICAgd2luc3RvbkxvZ2dlci5kZWJ1Zyh7IG1lc3NhZ2U6IG1zZywgbGFiZWw6IHRoaXMuZmlsZU5hbWUgfSk7XG4gICAgfVxuICB9XG4gIGluZm8obXNnOiBzdHJpbmcpOiB2b2lkIHtcbiAgICB3aW5zdG9uTG9nZ2VyLmluZm8oeyBtZXNzYWdlOiBtc2csIGxhYmVsOiB0aGlzLmZpbGVOYW1lIH0pO1xuICB9XG4gIHNldERlYnVnKGRlYnVnOiBib29sZWFuKTogdm9pZCB7XG4gICAgTG9nZ2VyLmRlYnVnU3RhdGUgPSBkZWJ1ZztcbiAgfVxufVxuIl19 |
{ | ||
"name": "@icon-magic/logger", | ||
"version": "2.0.1-beta.0", | ||
"version": "2.2.8-beta.0", | ||
"description": "Icon magic logger package.", | ||
@@ -20,3 +20,4 @@ "main": "dist/src/index.js", | ||
"winston": "^3.2.1" | ||
} | ||
}, | ||
"gitHead": "f8ef6904a3d74ae7ca9a014bf7e6a98d133fbed9" | ||
} |
@@ -19,12 +19,12 @@ # @icon-magic/logger | ||
// Import the logger module and it's interface | ||
import { Logger, logger } from '@icon-magic/logger'; | ||
import { Logger } from "@icon-magic/logger"; | ||
// Instantiate by passing the name of the file. This will be a label in the log message | ||
const LOGGER: logger = logger('icon-magic:icon-models:asset'); | ||
const LOGGER: logger = new Logger("icon-magic:icon-models:asset"); | ||
// Log a debug message | ||
LOGGER.debug('Icon generation has begun'); | ||
LOGGER.debug("Icon generation has begun"); | ||
// Log an error message | ||
LOGGER.error('Oh no! An error has occurred!'); | ||
LOGGER.error("Oh no! An error has occurred!"); | ||
``` | ||
@@ -31,0 +31,0 @@ |
@@ -25,6 +25,7 @@ import { createLogger, format, transports } from 'winston'; | ||
*/ | ||
export interface Logger { | ||
error: (msg: string) => void; | ||
debug: (msg: string) => void; | ||
info: (msg: string) => void; | ||
interface LoggerInterface { | ||
error(msg: string): void; | ||
debug(msg: string): void; | ||
info(msg: string): void; | ||
setDebug(debug: boolean): void; | ||
} | ||
@@ -34,16 +35,26 @@ | ||
* Wrapper around winston's logger that takes in a fileName | ||
* @const debugState <boolean> defaults to false, passed in from cli flags. | ||
* Using commander, -d or --debug flag will make this true. | ||
* @param fileName name of the file that's added as a label to the logging data | ||
*/ | ||
export function logger(fileName: string): Logger { | ||
return { | ||
error: function(msg: string): void { | ||
winstonLogger.error({ message: msg, label: fileName }); | ||
}, | ||
debug: function(msg: string): void { | ||
winstonLogger.debug({ message: msg, label: fileName }); | ||
}, | ||
info: function(msg: string): void { | ||
winstonLogger.info({ message: msg, label: fileName }); | ||
export class Logger implements LoggerInterface{ | ||
fileName: string; | ||
static debugState: boolean = false; | ||
constructor(fileName: string) { | ||
this.fileName = fileName; | ||
} | ||
error(msg: string = ''): void { | ||
winstonLogger.error({ message: msg, label: this.fileName }); | ||
} | ||
debug(msg: string = ''): void { | ||
if (Logger.debugState) { | ||
winstonLogger.debug({ message: msg, label: this.fileName }); | ||
} | ||
}; | ||
} | ||
info(msg: string): void { | ||
winstonLogger.info({ message: msg, label: this.fileName }); | ||
} | ||
setDebug(debug: boolean): void { | ||
Logger.debugState = debug; | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
152
13642