@ecopages/logger
Advanced tools
+7
-1
@@ -0,1 +1,4 @@ | ||
| interface LoggerOptions { | ||
| debug?: boolean; | ||
| } | ||
| /** | ||
@@ -6,2 +9,3 @@ * Represents a logger that can be used to log messages with different log levels. | ||
| private readonly prefix; | ||
| private options; | ||
| /** | ||
@@ -11,3 +15,3 @@ * Creates a new instance of the Logger class. | ||
| */ | ||
| constructor(prefix: string); | ||
| constructor(prefix: string, options?: LoggerOptions); | ||
| /** | ||
@@ -30,2 +34,3 @@ * Logs an informational message. | ||
| * Logs a debug message. | ||
| * This method will only log messages if the debug option is set to true. | ||
| * @param args The arguments to be logged. | ||
@@ -36,1 +41,2 @@ */ | ||
| } | ||
| export {}; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| var k;(function(q){q["INFO"]="INFO";q["ERROR"]="ERROR";q["WARN"]="WARN";q["DEBUG"]="DEBUG"})(k||(k={}));var K={level:k.INFO},M={level:k.ERROR},P={level:k.WARN},Q={level:k.DEBUG};class V{prefix;constructor(j){this.prefix=j}info(...j){this.logInternal(K,...j)}warn(...j){this.logInternal(P,...j)}error(...j){this.logInternal(M,...j)}debug(...j){if(process.env.ECOPAGES_LOGGER_DEBUG==="true")this.logInternal(Q,...j)}logInternal(j,...H){const z=j?{[k.INFO]:"\x1B[32m",[k.ERROR]:"\x1B[31m",[k.WARN]:"\x1B[33m",[k.DEBUG]:"\x1B[36m"}[j.level]:"",J=`${z?z:""}${this.prefix}`;console.log(J,...H,"\x1B[0m")}}export{V as Logger}; | ||
| var H={level:"INFO"},J={level:"ERROR"},K={level:"WARN"},M={level:"DEBUG"};class P{prefix;options={debug:!1};constructor(j,k){if(this.prefix=j,k)this.options=k}info(...j){this.logInternal(H,...j)}warn(...j){this.logInternal(K,...j)}error(...j){this.logInternal(J,...j)}debug(...j){if(this.options.debug)this.logInternal(M,...j)}logInternal(j,...k){const q=j?{["INFO"]:"\x1B[32m",["ERROR"]:"\x1B[31m",["WARN"]:"\x1B[33m",["DEBUG"]:"\x1B[36m"}[j.level]:"",z=`${q?q:""}${this.prefix}`;console.log(z,...k,"\x1B[0m")}}export{P as Logger}; |
+1
-1
| { | ||
| "name": "@ecopages/logger", | ||
| "version": "0.1.2", | ||
| "version": "0.1.3", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "./dist/logger.js", |
+9
-4
@@ -66,7 +66,12 @@ # @ecopages/logger | ||
| Debugging Instructions | ||
| By default, the debugging feature is turned off. To enable it, please add the following line to your `.env` file: | ||
| ### Debugging Instructions | ||
| ```sh | ||
| ECOPAGES_LOGGER_DEBUG=true | ||
| By default, the debugging feature is turned off. To enable it you can provide an options object to the logger constructor. | ||
| ```ts | ||
| const logger = new Logger("[my-app]", { debug: true }); | ||
| ``` | ||
| ```bash | ||
| [my-app] This is a debug message | ||
| ``` |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
5644
3.41%41
17.14%77
6.94%0
-100%