sylog 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var b=Object.create;var i=Object.defineProperty;var
|
|
2
|
-
`};l.length&&this.isLogOpts(l[l.length-1])&&(o={...o,...l.pop()});let
|
|
1
|
+
"use strict";var b=Object.create;var i=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var v=(t,s)=>{for(var e in s)i(t,e,{get:s[e],enumerable:!0})},u=(t,s,e,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of w(s))!S.call(t,o)&&o!==e&&i(t,o,{get:()=>s[o],enumerable:!(l=y(s,o))||l.enumerable});return t};var f=(t,s,e)=>(e=t!=null?b(O(t)):{},u(s||!t||!t.__esModule?i(e,"default",{value:t,enumerable:!0}):e,t)),m=t=>u(i({},"__esModule",{value:!0}),t);var E={};v(E,{Sylog:()=>n,default:()=>A,sylog:()=>a});module.exports=m(E);var r=f(require("ansilory"),1),n=class{opts;LEVEL_COLORS={log:s=>r.default.white.apply(s),info:s=>r.default.blue.bold.apply(s),warn:s=>r.default.yellow.bold.apply(s),error:s=>r.default.red.bold.apply(s),success:s=>r.default.green.bold.apply(s),debug:s=>r.default.gray.bold.apply(s),dryrun:s=>r.default.magenta.bold.apply(s)};DEFAULT_OPTS={showTimeStamp:!1,timeStamp:"utc",showLevels:!0,debug:!1,levels:{log:null,info:"INFO",warn:"WARN",error:"ERROR",success:"SUCCESS",debug:"DEBUG",dryrun:"DRYRUN"}};constructor(s){this.opts={...this.DEFAULT_OPTS,...s}}isLogOpts(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)&&("sep"in s||"end"in s||"label"in s)}write(s,e,...l){let o={sep:" ",end:`
|
|
2
|
+
`};l.length&&this.isLogOpts(l[l.length-1])&&(o={...o,...l.pop()});let d=this.opts.showTimeStamp?r.default.gray.apply(`[${this.opts.timeStamp==="utc"?new Date().toISOString().replace("T"," ").slice(0,19):new Date().toLocaleString("sv-SE")}]`):"",c=l.map(p=>typeof p=="object"&&p!==null?JSON.stringify(p):String(p)).join(o.sep),g=o.label??this.opts.levels?.[e],h=g?this.LEVEL_COLORS[e](`[${g}]`):null,L=[this.opts.prefix&&r.default.gray.bold.apply(this.opts.prefix),d,this.opts.showLevels&&h,c].filter(Boolean).join(" ")+o.end;s.write(L)}enableDebug(){this.opts.debug=!0}disableDebug(){this.opts.debug=!1}isDebugEnabled(){return!!this.opts.debug}setLevels(s){this.opts.levels={...this.opts.levels,...s}}getLevels(){return{...this.opts.levels}}log(...s){this.write(process.stdout,"log",...s)}info(...s){this.write(process.stdout,"info",...s)}warn(...s){this.write(process.stderr,"warn",...s)}error(...s){this.write(process.stderr,"error",...s)}success(...s){this.write(process.stdout,"success",...s)}debug(...s){this.opts.debug&&this.write(process.stdout,"debug",...s)}dryrun(...s){this.write(process.stdout,"dryrun",...s)}},a=new n,A=a;0&&(module.exports={Sylog,sylog});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Log levels */
|
|
2
|
-
type Levels = 'log' | 'info' | 'warn' | 'error' | 'success' | 'debug';
|
|
2
|
+
type Levels = 'log' | 'info' | 'warn' | 'error' | 'success' | 'debug' | 'dryrun';
|
|
3
3
|
/**
|
|
4
4
|
* - Arguments passed to log methods.
|
|
5
5
|
* - Last argument can optionally be {@link LogOpts} to customize.
|
|
@@ -155,6 +155,7 @@ declare class Sylog {
|
|
|
155
155
|
error?: string | null | undefined;
|
|
156
156
|
success?: string | null | undefined;
|
|
157
157
|
debug?: string | null | undefined;
|
|
158
|
+
dryrun?: string | null | undefined;
|
|
158
159
|
};
|
|
159
160
|
/**
|
|
160
161
|
* Logs a general message
|
|
@@ -210,6 +211,15 @@ declare class Sylog {
|
|
|
210
211
|
* ```
|
|
211
212
|
*/
|
|
212
213
|
debug(...args: LogArgs): void;
|
|
214
|
+
/**
|
|
215
|
+
* Logs a dry-run message
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* sylog.dryrun('Dry run mode enabled');
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
dryrun(...args: LogArgs): void;
|
|
213
223
|
}
|
|
214
224
|
/**
|
|
215
225
|
* Default singleton
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Log levels */
|
|
2
|
-
type Levels = 'log' | 'info' | 'warn' | 'error' | 'success' | 'debug';
|
|
2
|
+
type Levels = 'log' | 'info' | 'warn' | 'error' | 'success' | 'debug' | 'dryrun';
|
|
3
3
|
/**
|
|
4
4
|
* - Arguments passed to log methods.
|
|
5
5
|
* - Last argument can optionally be {@link LogOpts} to customize.
|
|
@@ -155,6 +155,7 @@ declare class Sylog {
|
|
|
155
155
|
error?: string | null | undefined;
|
|
156
156
|
success?: string | null | undefined;
|
|
157
157
|
debug?: string | null | undefined;
|
|
158
|
+
dryrun?: string | null | undefined;
|
|
158
159
|
};
|
|
159
160
|
/**
|
|
160
161
|
* Logs a general message
|
|
@@ -210,6 +211,15 @@ declare class Sylog {
|
|
|
210
211
|
* ```
|
|
211
212
|
*/
|
|
212
213
|
debug(...args: LogArgs): void;
|
|
214
|
+
/**
|
|
215
|
+
* Logs a dry-run message
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* sylog.dryrun('Dry run mode enabled');
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
dryrun(...args: LogArgs): void;
|
|
213
223
|
}
|
|
214
224
|
/**
|
|
215
225
|
* Default singleton
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
`};
|
|
1
|
+
import t from"ansilory";var l=class{opts;LEVEL_COLORS={log:s=>t.white.apply(s),info:s=>t.blue.bold.apply(s),warn:s=>t.yellow.bold.apply(s),error:s=>t.red.bold.apply(s),success:s=>t.green.bold.apply(s),debug:s=>t.gray.bold.apply(s),dryrun:s=>t.magenta.bold.apply(s)};DEFAULT_OPTS={showTimeStamp:!1,timeStamp:"utc",showLevels:!0,debug:!1,levels:{log:null,info:"INFO",warn:"WARN",error:"ERROR",success:"SUCCESS",debug:"DEBUG",dryrun:"DRYRUN"}};constructor(s){this.opts={...this.DEFAULT_OPTS,...s}}isLogOpts(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)&&("sep"in s||"end"in s||"label"in s)}write(s,p,...e){let o={sep:" ",end:`
|
|
2
|
+
`};e.length&&this.isLogOpts(e[e.length-1])&&(o={...o,...e.pop()});let n=this.opts.showTimeStamp?t.gray.apply(`[${this.opts.timeStamp==="utc"?new Date().toISOString().replace("T"," ").slice(0,19):new Date().toLocaleString("sv-SE")}]`):"",g=e.map(r=>typeof r=="object"&&r!==null?JSON.stringify(r):String(r)).join(o.sep),i=o.label??this.opts.levels?.[p],u=i?this.LEVEL_COLORS[p](`[${i}]`):null,a=[this.opts.prefix&&t.gray.bold.apply(this.opts.prefix),n,this.opts.showLevels&&u,g].filter(Boolean).join(" ")+o.end;s.write(a)}enableDebug(){this.opts.debug=!0}disableDebug(){this.opts.debug=!1}isDebugEnabled(){return!!this.opts.debug}setLevels(s){this.opts.levels={...this.opts.levels,...s}}getLevels(){return{...this.opts.levels}}log(...s){this.write(process.stdout,"log",...s)}info(...s){this.write(process.stdout,"info",...s)}warn(...s){this.write(process.stderr,"warn",...s)}error(...s){this.write(process.stderr,"error",...s)}success(...s){this.write(process.stdout,"success",...s)}debug(...s){this.opts.debug&&this.write(process.stdout,"debug",...s)}dryrun(...s){this.write(process.stdout,"dryrun",...s)}},d=new l,L=d;export{l as Sylog,L as default,d as sylog};
|