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 CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var b=Object.create;var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var v=(e,s)=>{for(var t in s)i(e,t,{get:s[t],enumerable:!0})},a=(e,s,t,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of y(s))!S.call(e,o)&&o!==t&&i(e,o,{get:()=>s[o],enumerable:!(l=w(s,o))||l.enumerable});return e};var f=(e,s,t)=>(t=e!=null?b(O(e)):{},a(s||!e||!e.__esModule?i(t,"default",{value:e,enumerable:!0}):t,e)),m=e=>a(i({},"__esModule",{value:!0}),e);var E={};v(E,{Sylog:()=>n,default:()=>A,sylog:()=>u});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.cyan.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"}};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,t,...l){let o={sep:" ",end:`
2
- `};l.length&&this.isLogOpts(l[l.length-1])&&(o={...o,...l.pop()});let c=this.opts.showTimeStamp?r.default.gray.apply(`[${this.opts.timeStamp==="utc"?new Date().toISOString().replace("T"," ").slice(0,19):new Date().toLocaleString("sv-SE")}]`):"",d=l.map(p=>typeof p=="object"&&p!==null?JSON.stringify(p):String(p)).join(o.sep),g=o.label??this.opts.levels?.[t],h=g?this.LEVEL_COLORS[t](`[${g}]`):null,L=[this.opts.prefix&&r.default.gray.bold.apply(this.opts.prefix),c,this.opts.showLevels&&h,d].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)}},u=new n,A=u;0&&(module.exports={Sylog,sylog});
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 e from"ansilory";var l=class{opts;LEVEL_COLORS={log:s=>e.white.apply(s),info:s=>e.blue.bold.apply(s),warn:s=>e.yellow.bold.apply(s),error:s=>e.red.bold.apply(s),success:s=>e.green.bold.apply(s),debug:s=>e.cyan.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"}};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,...t){let o={sep:" ",end:`
2
- `};t.length&&this.isLogOpts(t[t.length-1])&&(o={...o,...t.pop()});let n=this.opts.showTimeStamp?e.gray.apply(`[${this.opts.timeStamp==="utc"?new Date().toISOString().replace("T"," ").slice(0,19):new Date().toLocaleString("sv-SE")}]`):"",g=t.map(r=>typeof r=="object"&&r!==null?JSON.stringify(r):String(r)).join(o.sep),i=o.label??this.opts.levels?.[p],a=i?this.LEVEL_COLORS[p](`[${i}]`):null,u=[this.opts.prefix&&e.gray.bold.apply(this.opts.prefix),n,this.opts.showLevels&&a,g].filter(Boolean).join(" ")+o.end;s.write(u)}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)}},c=new l,L=c;export{l as Sylog,L as default,c as sylog};
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};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sylog",
3
3
  "displayName": "Sylog",
4
- "version": "2.0.0",
4
+ "version": "2.1.0",
5
5
  "description": "Sync system logs terminal clarity file durability",
6
6
  "private": false,
7
7
  "repository": {