sylog 1.0.0 → 2.0.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 w=Object.create;var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var f=(s,t)=>{for(var e in t)l(s,e,{get:t[e],enumerable:!0})},c=(s,t,e,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of O(t))!m.call(s,o)&&o!==e&&l(s,o,{get:()=>t[o],enumerable:!(p=y(t,o))||p.enumerable});return s};var b=(s,t,e)=>(e=s!=null?w(S(s)):{},c(t||!s||!s.__esModule?l(e,"default",{value:s,enumerable:!0}):e,s)),v=s=>c(l({},"__esModule",{value:!0}),s);var E={};f(E,{Sylog:()=>n,default:()=>A,sylog:()=>a});module.exports=v(E);var r=b(require("ansilory"),1),n=class{opts;LEVEL_COLORS={log:t=>r.default.white.apply(t),info:t=>r.default.blue.bold.apply(t),warn:t=>r.default.yellow.bold.apply(t),error:t=>r.default.red.bold.apply(t),success:t=>r.default.green.bold.apply(t),debug:t=>r.default.cyan.bold.apply(t)};DEFAULT_OPTS={showTimeStamp:!1,timeStamp:"utc",showLevels:!0,levels:{log:null,info:"INFO",warn:"WARN",error:"ERROR",success:"SUCCESS",debug:"DEBUG"}};constructor(t){this.opts={...this.DEFAULT_OPTS,...t}}isLogOpts(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&("sep"in t||"end"in t)}write(t,e,...p){let o={sep:" ",end:`
2
- `};p.length&&this.isLogOpts(p[p.length-1])&&(o={...o,...p.pop()});let L=this.opts.showTimeStamp?r.default.gray.apply(`[${this.opts.timeStamp==="utc"?new Date().toISOString().replace("T"," ").slice(0,19):new Date().toLocaleString("sv-SE")}]`):"",u=p.map(i=>typeof i=="object"&&i!==null?JSON.stringify(i):String(i)).join(o.sep),g=this.opts.levels?.[e],d=g?this.LEVEL_COLORS[e](`[${g}]`):null,h=[this.opts.prefix&&r.default.gray.bold.apply(this.opts.prefix),L,this.opts.showLevels&&d,u].filter(Boolean).join(" ")+o.end;t.write(h)}log(...t){this.write(process.stdout,"log",...t)}info(...t){this.write(process.stdout,"info",...t)}warn(...t){this.write(process.stderr,"warn",...t)}error(...t){this.write(process.stderr,"error",...t)}success(...t){this.write(process.stdout,"success",...t)}debug(...t){this.write(process.stdout,"debug",...t)}},a=new n,A=a;0&&(module.exports={Sylog,sylog});
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});
package/dist/index.d.cts CHANGED
@@ -31,6 +31,12 @@ interface SylogOpts {
31
31
  showLevels?: boolean;
32
32
  /** Custom names for each level or null to hide */
33
33
  levels?: Partial<Record<Levels, string | null>>;
34
+ /**
35
+ * Enables debug output
36
+ *
37
+ * @default false
38
+ */
39
+ debug?: boolean;
34
40
  }
35
41
  /** Options for a log call */
36
42
  interface LogOpts {
@@ -46,6 +52,10 @@ interface LogOpts {
46
52
  * @default "\n"
47
53
  */
48
54
  end?: string;
55
+ /**
56
+ * Override the default level label
57
+ */
58
+ label?: string;
49
59
  }
50
60
 
51
61
  /**
@@ -63,6 +73,24 @@ interface LogOpts {
63
73
  * logger.success('Task completed successfully');
64
74
  * logger.debug('Debug info', { foo: 'bar' });
65
75
  * ```
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * import { sylog } from 'sylog';
80
+ *
81
+ * sylog.info('Starting server...');
82
+ * sylog.success('Server started successfully!');
83
+ *
84
+ * // Enable debug logs
85
+ * sylog.enableDebug();
86
+ * sylog.debug('Debug mode active', { label: 'Trace' });
87
+ *
88
+ * // Customize global labels at runtime
89
+ * sylog.setLevels({ info: 'ℹ️', success: '✅', error: '❌' });
90
+ *
91
+ * // Per-call label override
92
+ * sylog.info('Startup complete', { label: 'Information' });
93
+ * ```
66
94
  */
67
95
  declare class Sylog {
68
96
  private opts;
@@ -74,6 +102,60 @@ declare class Sylog {
74
102
  constructor(options?: SylogOpts);
75
103
  private isLogOpts;
76
104
  private write;
105
+ /**
106
+ * Enables debug mode.
107
+ *
108
+ * When enabled, `debug()` logs will be printed to the console.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * sylog.enableDebug();
113
+ * sylog.debug('Verbose details');
114
+ * ```
115
+ */
116
+ enableDebug(): void;
117
+ /**
118
+ * Disables debug mode.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * sylog.disableDebug();
123
+ * sylog.debug('This will not print');
124
+ * ```
125
+ */
126
+ disableDebug(): void;
127
+ /**
128
+ * Returns whether debug mode is currently enabled.
129
+ *
130
+ * @returns `true` if debug mode is active.
131
+ */
132
+ isDebugEnabled(): boolean;
133
+ /**
134
+ * Updates log level labels globally at runtime.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * sylog.setLevels({ info: 'ℹ️ Info', success: '✅ Done' });
139
+ * ```
140
+ */
141
+ setLevels(
142
+ /**
143
+ * A partial map of log levels and new label strings.
144
+ */
145
+ levels: SylogOpts['levels']): void;
146
+ /**
147
+ * Returns the current log level label configuration.
148
+ *
149
+ * @returns A copy of the internal levels map.
150
+ */
151
+ getLevels(): {
152
+ log?: string | null | undefined;
153
+ info?: string | null | undefined;
154
+ warn?: string | null | undefined;
155
+ error?: string | null | undefined;
156
+ success?: string | null | undefined;
157
+ debug?: string | null | undefined;
158
+ };
77
159
  /**
78
160
  * Logs a general message
79
161
  *
package/dist/index.d.ts CHANGED
@@ -31,6 +31,12 @@ interface SylogOpts {
31
31
  showLevels?: boolean;
32
32
  /** Custom names for each level or null to hide */
33
33
  levels?: Partial<Record<Levels, string | null>>;
34
+ /**
35
+ * Enables debug output
36
+ *
37
+ * @default false
38
+ */
39
+ debug?: boolean;
34
40
  }
35
41
  /** Options for a log call */
36
42
  interface LogOpts {
@@ -46,6 +52,10 @@ interface LogOpts {
46
52
  * @default "\n"
47
53
  */
48
54
  end?: string;
55
+ /**
56
+ * Override the default level label
57
+ */
58
+ label?: string;
49
59
  }
50
60
 
51
61
  /**
@@ -63,6 +73,24 @@ interface LogOpts {
63
73
  * logger.success('Task completed successfully');
64
74
  * logger.debug('Debug info', { foo: 'bar' });
65
75
  * ```
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * import { sylog } from 'sylog';
80
+ *
81
+ * sylog.info('Starting server...');
82
+ * sylog.success('Server started successfully!');
83
+ *
84
+ * // Enable debug logs
85
+ * sylog.enableDebug();
86
+ * sylog.debug('Debug mode active', { label: 'Trace' });
87
+ *
88
+ * // Customize global labels at runtime
89
+ * sylog.setLevels({ info: 'ℹ️', success: '✅', error: '❌' });
90
+ *
91
+ * // Per-call label override
92
+ * sylog.info('Startup complete', { label: 'Information' });
93
+ * ```
66
94
  */
67
95
  declare class Sylog {
68
96
  private opts;
@@ -74,6 +102,60 @@ declare class Sylog {
74
102
  constructor(options?: SylogOpts);
75
103
  private isLogOpts;
76
104
  private write;
105
+ /**
106
+ * Enables debug mode.
107
+ *
108
+ * When enabled, `debug()` logs will be printed to the console.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * sylog.enableDebug();
113
+ * sylog.debug('Verbose details');
114
+ * ```
115
+ */
116
+ enableDebug(): void;
117
+ /**
118
+ * Disables debug mode.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * sylog.disableDebug();
123
+ * sylog.debug('This will not print');
124
+ * ```
125
+ */
126
+ disableDebug(): void;
127
+ /**
128
+ * Returns whether debug mode is currently enabled.
129
+ *
130
+ * @returns `true` if debug mode is active.
131
+ */
132
+ isDebugEnabled(): boolean;
133
+ /**
134
+ * Updates log level labels globally at runtime.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * sylog.setLevels({ info: 'ℹ️ Info', success: '✅ Done' });
139
+ * ```
140
+ */
141
+ setLevels(
142
+ /**
143
+ * A partial map of log levels and new label strings.
144
+ */
145
+ levels: SylogOpts['levels']): void;
146
+ /**
147
+ * Returns the current log level label configuration.
148
+ *
149
+ * @returns A copy of the internal levels map.
150
+ */
151
+ getLevels(): {
152
+ log?: string | null | undefined;
153
+ info?: string | null | undefined;
154
+ warn?: string | null | undefined;
155
+ error?: string | null | undefined;
156
+ success?: string | null | undefined;
157
+ debug?: string | null | undefined;
158
+ };
77
159
  /**
78
160
  * Logs a general message
79
161
  *
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import s from"ansilory";var p=class{opts;LEVEL_COLORS={log:t=>s.white.apply(t),info:t=>s.blue.bold.apply(t),warn:t=>s.yellow.bold.apply(t),error:t=>s.red.bold.apply(t),success:t=>s.green.bold.apply(t),debug:t=>s.cyan.bold.apply(t)};DEFAULT_OPTS={showTimeStamp:!1,timeStamp:"utc",showLevels:!0,levels:{log:null,info:"INFO",warn:"WARN",error:"ERROR",success:"SUCCESS",debug:"DEBUG"}};constructor(t){this.opts={...this.DEFAULT_OPTS,...t}}isLogOpts(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&("sep"in t||"end"in t)}write(t,i,...e){let o={sep:" ",end:`
2
- `};e.length&&this.isLogOpts(e[e.length-1])&&(o={...o,...e.pop()});let n=this.opts.showTimeStamp?s.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),l=this.opts.levels?.[i],c=l?this.LEVEL_COLORS[i](`[${l}]`):null,a=[this.opts.prefix&&s.gray.bold.apply(this.opts.prefix),n,this.opts.showLevels&&c,g].filter(Boolean).join(" ")+o.end;t.write(a)}log(...t){this.write(process.stdout,"log",...t)}info(...t){this.write(process.stdout,"info",...t)}warn(...t){this.write(process.stderr,"warn",...t)}error(...t){this.write(process.stderr,"error",...t)}success(...t){this.write(process.stdout,"success",...t)}debug(...t){this.write(process.stdout,"debug",...t)}},L=new p,h=L;export{p as Sylog,h as default,L as sylog};
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};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sylog",
3
3
  "displayName": "Sylog",
4
- "version": "1.0.0",
4
+ "version": "2.0.0",
5
5
  "description": "Sync system logs terminal clarity file durability",
6
6
  "private": false,
7
7
  "repository": {