@mks2508/better-logger 3.0.0 → 4.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/.claude/settings.local.json +3 -1
- package/CHANGELOG.json +98 -1
- package/dist/Logger.d.ts +24 -12
- package/dist/Logger.d.ts.map +1 -1
- package/dist/chunks/{Logger-C126NTrD.js → Logger-D-gmmgR2.js} +207 -18
- package/dist/chunks/Logger-D-gmmgR2.js.map +1 -0
- package/dist/chunks/Logger-D7cfaz15.js +2 -0
- package/dist/chunks/Logger-D7cfaz15.js.map +1 -0
- package/dist/chunks/{environment-TI2ByCPT.js → environment-COWvu6Wz.js} +466 -98
- package/dist/chunks/environment-COWvu6Wz.js.map +1 -0
- package/dist/chunks/environment-C_8J-zQ_.js +4 -0
- package/dist/chunks/environment-C_8J-zQ_.js.map +1 -0
- package/dist/chunks/{formatting-CuNUqGks.js → formatting-CYjT9yhO.js} +2 -2
- package/dist/chunks/{formatting-CuNUqGks.js.map → formatting-CYjT9yhO.js.map} +1 -1
- package/dist/chunks/{formatting-Blwy-f0W.js → formatting-Cg5YhB9Y.js} +2 -2
- package/dist/chunks/{formatting-Blwy-f0W.js.map → formatting-Cg5YhB9Y.js.map} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +2 -2
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +151 -20
- package/dist/index.js.map +1 -1
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +3 -3
- package/dist/terminal/color-converter.d.ts +73 -0
- package/dist/terminal/color-converter.d.ts.map +1 -0
- package/dist/terminal/formatter.d.ts +20 -0
- package/dist/terminal/formatter.d.ts.map +1 -0
- package/dist/terminal/terminal-renderer.d.ts +20 -6
- package/dist/terminal/terminal-renderer.d.ts.map +1 -1
- package/dist/types/core.d.ts +61 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/environment-detector.d.ts +10 -0
- package/dist/utils/environment-detector.d.ts.map +1 -1
- package/dist/writers/BufferWriter.d.ts +96 -0
- package/dist/writers/BufferWriter.d.ts.map +1 -0
- package/dist/writers/index.d.ts +6 -0
- package/dist/writers/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/packages/styling/package.json +2 -2
- package/src/Logger.ts +63 -21
- package/src/index.ts +61 -2
- package/src/terminal/color-converter.ts +315 -0
- package/src/terminal/formatter.ts +236 -0
- package/src/terminal/terminal-renderer.ts +74 -79
- package/src/types/core.ts +68 -0
- package/src/types/index.ts +5 -0
- package/src/utils/environment-detector.ts +23 -1
- package/src/writers/BufferWriter.ts +157 -0
- package/src/writers/index.ts +6 -0
- package/dist/chunks/Logger-BCfx_yCK.js +0 -2
- package/dist/chunks/Logger-BCfx_yCK.js.map +0 -1
- package/dist/chunks/Logger-C126NTrD.js.map +0 -1
- package/dist/chunks/environment-Ba5kShbx.js +0 -4
- package/dist/chunks/environment-Ba5kShbx.js.map +0 -1
- package/dist/chunks/environment-TI2ByCPT.js.map +0 -1
package/dist/core.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/environment-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/environment-C_8J-zQ_.js"),o=require("./chunks/formatting-Cg5YhB9Y.js");class CoreLogger{config;scopedPrefix;handlers=[];timers=/* @__PURE__ */new Map;groupDepth=0;constructor(o={}){this.config={...e.DEFAULT_CONFIG,...o,enableColors:o.enableColors??!!e.isBrowser,enableTimestamps:o.enableTimestamps??!0,enableStackTrace:o.enableStackTrace??!1,autoDetectTheme:o.autoDetectTheme??!0,outputFormat:o.outputFormat??"auto"}}getConfig(){return{...this.config}}setGlobalPrefix(e){this.config.globalPrefix=e}setVerbosity(e){this.config.verbosity=e}scope(e){const o=new CoreLogger(this.config);return o.scopedPrefix=e,o.handlers=[...this.handlers],o}addHandler(e){this.handlers.push(e)}shouldLog(e){if("silent"===this.config.verbosity)return!1;const o={debug:0,info:1,warn:2,error:3,critical:4};return o[e]>=o[this.config.verbosity]}getEffectivePrefix(){const e=[this.config.globalPrefix,this.scopedPrefix].filter(Boolean);return e.length>0?e.join(":"):void 0}log(t,...r){if(!this.shouldLog(t))return;const s=this.getEffectivePrefix(),i=String(r[0]||""),n=this.config.enableStackTrace?e.parseStackTrace():null,c=o.getConsoleMethod(t);if(e.isBrowser&&this.config.enableColors&&e.supportsCSSColors())try{const[o,...l]=e.createStyledOutput(t,e.LEVEL_STYLES,s,i,n,this.config.autoDetectTheme);console[c](o,...l,...r.slice(1))}catch(g){const e=o.createOutput(t,i,s,n,this.config.outputFormat);console[c](e,...r.slice(1))}else{const e=" ".repeat(this.groupDepth)+o.createOutput(t,i,s,n,this.config.outputFormat);console[c](e,...r.slice(1))}const l=o.createLogEntry(t,i,r,s,n),a={timestamp:l.timestamp,level:t,prefix:s,stackInfo:l.location};this.handlers.forEach(e=>{try{e.handle(t,i,r,a)}catch(g){console.error("Log handler failed:",g)}})}debug(...e){this.log("debug",...e)}info(...e){this.log("info",...e)}warn(...e){this.log("warn",...e)}error(...e){this.log("error",...e)}critical(...e){this.log("critical",...e)}trace(...e){this.log("debug",...e),this.shouldLog("debug")&&console.trace(...e)}table(t,r){if(!this.shouldLog("info"))return;const s=this.getEffectivePrefix(),i=`[TABLE]${s?` [${s}]`:""}:`;if(e.isBrowser&&"function"==typeof console.table)console.log(i),r?console.table(t,r):console.table(t);else{console.log(i);const e=o.formatTablePlain(t,r);console.log(e)}}group(o,t=!1){const r=this.getEffectivePrefix(),s=`${r?`[${r}] `:""}${o}`;if(e.isBrowser&&console.group&&console.groupCollapsed)t?console.groupCollapsed(s):console.group(s);else{const e="┌─ "+s;console.log(e)}this.groupDepth++}groupEnd(){if(this.groupDepth>0){if(e.isBrowser&&console.groupEnd)console.groupEnd();else{const e="└─ (end group)";console.log(e)}this.groupDepth--}}time(e){const t={label:e,startTime:this.getPerformanceNow()};this.timers.set(e,t);const r=this.getEffectivePrefix(),s=`Timer started: ${e}`,i=o.createPlainOutput("info",s,r);console.log(i)}timeEnd(e){const t=this.timers.get(e);if(!t)return void this.warn(`Timer '${e}' does not exist`);const r=this.getPerformanceNow()-t.startTime;this.timers.delete(e);const s=this.getEffectivePrefix(),i=`Timer ended: ${e} - ${r.toFixed(2)}ms`,n=o.createPlainOutput("info",i,s);console.log(n)}getPerformanceNow(){if("undefined"!=typeof performance&&performance.now)return performance.now();if(e.isNode&&process.hrtime){const[e,o]=process.hrtime();return 1e3*e+o/1e6}return Date.now()}}const t=new CoreLogger;exports.CoreLogger=CoreLogger,exports.addHandler=e=>t.addHandler(e),exports.critical=(...e)=>t.critical(...e),exports.debug=(...e)=>t.debug(...e),exports.default=t,exports.error=(...e)=>t.error(...e),exports.group=(e,o)=>t.group(e,o),exports.groupEnd=()=>t.groupEnd(),exports.info=(...e)=>t.info(...e),exports.scope=e=>t.scope(e),exports.setGlobalPrefix=e=>t.setGlobalPrefix(e),exports.setVerbosity=e=>t.setVerbosity(e),exports.table=(e,o)=>t.table(e,o),exports.time=e=>t.time(e),exports.timeEnd=e=>t.timeEnd(e),exports.trace=(...e)=>t.trace(...e),exports.warn=(...e)=>t.warn(...e);
|
|
2
2
|
//# sourceMappingURL=core.cjs.map
|
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DEFAULT_CONFIG, a as isBrowser, p as parseStackTrace,
|
|
2
|
-
import { o as getConsoleMethod, c as createOutput, p as createLogEntry, q as formatTablePlain, r as createPlainOutput } from "./chunks/formatting-
|
|
1
|
+
import { D as DEFAULT_CONFIG, a as isBrowser, p as parseStackTrace, x as supportsCSSColors, y as createStyledOutput, L as LEVEL_STYLES, i as isNode } from "./chunks/environment-COWvu6Wz.js";
|
|
2
|
+
import { o as getConsoleMethod, c as createOutput, p as createLogEntry, q as formatTablePlain, r as createPlainOutput } from "./chunks/formatting-CYjT9yhO.js";
|
|
3
3
|
class CoreLogger {
|
|
4
4
|
config;
|
|
5
5
|
scopedPrefix;
|
package/dist/exports.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/Logger-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/Logger-D7cfaz15.js");require("./chunks/environment-C_8J-zQ_.js");const r=require("./chunks/RemoteLogHandler-ymkQ97xl.js");class ExportLogger extends e.Logger{exportLogHandler;remoteHandlers=[];constructor(r={}){super(r),r.bufferSize&&(this.exportLogHandler=new e.ExportLogHandler(r.bufferSize),this.addHandler(this.exportLogHandler))}async exportLogs(e,r){if(!this.exportLogHandler)throw new Error("Export handler not initialized. Set bufferSize in constructor.");return JSON.stringify([])}getLogs(){return this.exportLogHandler,[]}clearLogs(){this.exportLogHandler}getLogStats(){return this.exportLogHandler,{}}addRemoteHandler(e,t){const o=new r.RemoteLogHandler(e,t);this.remoteHandlers.push(o),this.addHandler(o)}clearRemoteHandlers(){const e=this.getHandlers();this.remoteHandlers.forEach(r=>{const t=e.indexOf(r);t>-1&&e.splice(t,1)}),this.remoteHandlers=[]}async flushRemoteHandlers(){const e=this.remoteHandlers.map(e=>Promise.resolve());await Promise.all(e)}}const t=new ExportLogger({bufferSize:1e3}),o={exportCSV:async e=>await t.exportLogs("csv",e),exportJSON:async e=>await t.exportLogs("json",e),exportXML:async e=>await t.exportLogs("xml",e),getStats:()=>t.getLogStats(),clear(){t.clearLogs()}},s={addEndpoint(e,r){t.addRemoteHandler(e,r)},clearEndpoints(){t.clearRemoteHandlers()},async flush(){await t.flushRemoteHandlers()}};exports.ExportLogHandler=e.ExportLogHandler,exports.RemoteLogHandler=r.RemoteLogHandler,exports.ExportLogger=ExportLogger,exports.addHandler=e=>t.addHandler(e),exports.addRemoteHandler=(e,r)=>t.addRemoteHandler(e,r),exports.clearLogs=()=>t.clearLogs(),exports.clearRemoteHandlers=()=>t.clearRemoteHandlers(),exports.critical=(...e)=>t.critical(...e),exports.debug=(...e)=>t.debug(...e),exports.default=t,exports.error=(...e)=>t.error(...e),exports.exportLogs=async(e,r)=>await t.exportLogs(e,r),exports.exportUtils=o,exports.flushRemoteHandlers=async()=>await t.flushRemoteHandlers(),exports.getLogStats=()=>t.getLogStats(),exports.getLogs=()=>t.getLogs(),exports.group=(e,r)=>t.group(e,r),exports.groupEnd=()=>t.groupEnd(),exports.info=(...e)=>t.info(...e),exports.remoteUtils=s,exports.scope=e=>t.scope(e),exports.setGlobalPrefix=e=>t.setGlobalPrefix(e),exports.setVerbosity=e=>t.setVerbosity(e),exports.success=(...e)=>t.success(...e),exports.table=(e,r)=>t.table(e,r),exports.time=e=>t.time(e),exports.timeEnd=e=>t.timeEnd(e),exports.trace=(...e)=>t.trace(...e),exports.warn=(...e)=>t.warn(...e);
|
|
2
2
|
//# sourceMappingURL=exports.cjs.map
|
package/dist/exports.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as Logger, E as ExportLogHandler } from "./chunks/Logger-
|
|
2
|
-
import "./chunks/environment-
|
|
1
|
+
import { L as Logger, E as ExportLogHandler } from "./chunks/Logger-D-gmmgR2.js";
|
|
2
|
+
import "./chunks/environment-COWvu6Wz.js";
|
|
3
3
|
import { R as RemoteLogHandler } from "./chunks/RemoteLogHandler-CjWpWZGl.js";
|
|
4
4
|
class ExportLogger extends Logger {
|
|
5
5
|
exportLogHandler;
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/Logger-BCfx_yCK.js"),t=require("./chunks/environment-Ba5kShbx.js"),s=require("./chunks/formatting-Blwy-f0W.js"),r=require("./chunks/RemoteLogHandler-ymkQ97xl.js"),o={maxEntries:100,ttl:3e5,enabled:!0};class StyleCache{cache=/* @__PURE__ */new Map;config;hitCount=0;missCount=0;constructor(e={}){this.config={...o,...e}}generateKey(e){return`${e.level}:${e.theme}:${e.presetName||"default"}:${e.hasPrefix}:${e.hasLocation}`}get(e){if(!this.config.enabled)return null;const t=this.generateKey(e),s=this.cache.get(t);return s?Date.now()-s.createdAt>this.config.ttl?(this.cache.delete(t),this.missCount++,null):(s.hits++,this.cache.delete(t),this.cache.set(t,s),this.hitCount++,s):(this.missCount++,null)}set(e,t,s){if(!this.config.enabled)return;const r=this.generateKey(e);if(this.cache.size>=this.config.maxEntries){const e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(r,{format:t,styles:[...s],createdAt:Date.now(),hits:0})}clear(){this.cache.clear(),this.hitCount=0,this.missCount=0}getStats(){const e=this.hitCount+this.missCount;return{size:this.cache.size,maxSize:this.config.maxEntries,hitRate:e>0?this.hitCount/e:0,hits:this.hitCount,misses:this.missCount}}setEnabled(e){this.config.enabled=e,e||this.clear()}isEnabled(){return this.config.enabled}}let i=null,n=null;function getLogger(){return n||(n=new e.Logger),n}const a=getLogger(),l={success:t.StylePresets.success().build(),error:t.StylePresets.error().build(),warning:t.StylePresets.warning().build(),info:t.StylePresets.info().build(),accent:t.StylePresets.accent().build()};exports.APILogger=e.APILogger,exports.BANNER_VARIANTS=e.BANNER_VARIANTS,exports.ComponentLogger=e.ComponentLogger,exports.ContextLogger=e.ContextLogger,exports.HookManager=e.HookManager,exports.Logger=e.Logger,exports.ScopedLogger=e.ScopedLogger,exports.SerializerRegistry=e.SerializerRegistry,exports.THEME_BANNERS=e.THEME_BANNERS,exports.THEME_PRESETS=e.THEME_PRESETS,exports.TransportManager=e.TransportManager,exports.BUILD_PRESETS=t.BUILD_PRESETS,exports.DEFAULT_CONFIG=t.DEFAULT_CONFIG,exports.ENVIRONMENT_DETECTION=t.ENVIRONMENT_DETECTION,exports.StyleBuilder=t.StyleBuilder,exports.StylePresets=t.StylePresets,exports.detectEnvironmentPreset=t.detectEnvironmentPreset,exports.formatTimestamp=t.formatTimestamp,exports.getOptimalConfig=t.getOptimalConfig,exports.parseStackTrace=t.parseStackTrace,exports.BUILD_FORMATTERS=s.BUILD_FORMATTERS,exports.ansiBackground=s.ansiBackground,exports.ansiBold=s.ansiBold,exports.ansiColor=s.ansiColor,exports.ansiDim=s.ansiDim,exports.ansiStyle=s.ansiStyle,exports.ansiUnderline=s.ansiUnderline,exports.createANSIOutput=s.createANSIOutput,exports.createBuildOutput=s.createBuildOutput,exports.createCIOutput=s.createCIOutput,exports.createOutput=s.createOutput,exports.detectOptimalFormat=s.detectOptimalFormat,exports.formatLogLevelANSI=s.formatLogLevelANSI,exports.formatSuccessANSI=s.formatSuccessANSI,exports.sanitizeEmojis=s.sanitizeEmojis,exports.RemoteLogHandler=r.RemoteLogHandler,exports.AnalyticsLogHandler=class{handle(e,t,s,r){"error"!==e&&"critical"!==e||r.timestamp}},exports.ConsoleTransport=class{constructor(e){this.options=e}name="console";write(e){const t=this.getConsoleMethod(e.level),s=e.prefix?`[${e.prefix}] `:"",r=e.location?` (${e.location.file}:${e.location.line})`:"";console[t](`[${e.level.toUpperCase()}]${s} ${e.msg}${r}`)}getConsoleMethod(e){switch(e){case"debug":default:return"log";case"info":return"info";case"warn":return"warn";case"error":case"critical":return"error"}}},exports.FileLogHandler=class{filename;maxSize;fs;constructor(e="app.log",s){if(this.filename=e,this.maxSize=s,t.isNode)try{this.fs=require("fs")}catch(r){console.warn("FileLogHandler: Unable to load fs module:",r)}}handle(e,r,o,i){const n={timestamp:i.timestamp,level:e.toUpperCase(),prefix:i.prefix,message:r,args:o.slice(1).map(e=>s.safeSerialize(e)),location:i.stackInfo},a=this.formatLogLine(n);t.isNode&&this.fs?this.writeToFileNode(a):t.isBrowser?this.writeToFileLocal(a):console.log(`[FILE-LOG] ${a}`)}formatLogLine(e){let t=[e.timestamp,`[${e.level}]`,e.prefix?`[${e.prefix}]`:"",e.message].filter(Boolean).join(" ");return e.args&&e.args.length>0&&(t+=" "+e.args.map(e=>"object"==typeof e?JSON.stringify(e):String(e)).join(" ")),e.location&&(t+=` (${e.location.file}:${e.location.line}:${e.location.column})`),t}writeToFileNode(e){if(this.fs)try{if(this.maxSize)try{if(this.fs.statSync(this.filename).size>this.maxSize){const e=`${this.filename}.bak`;this.fs.renameSync(this.filename,e)}}catch(t){}this.fs.appendFileSync(this.filename,e+"\n","utf8")}catch(t){console.error("FileLogHandler: Failed to write to file:",t)}}writeToFileLocal(e){try{const t=`logger_${this.filename}`,s=localStorage.getItem(t)||"";let r=s;if(s.length>0&&(r+="\n"),r+=e,this.maxSize||r.split("\n").length>1e3){const e=r.split("\n"),t=this.maxSize?Math.floor(this.maxSize/100):1e3;e.length>t&&(r=e.slice(-t).join("\n"))}localStorage.setItem(t,r)}catch(t){console.error("FileLogHandler: Failed to write to localStorage:",t)}}getLogs(){if(t.isNode&&this.fs)try{return this.fs.readFileSync(this.filename,"utf8")}catch(e){return null}else if(t.isBrowser){const e=`logger_${this.filename}`;return localStorage.getItem(e)}return null}clearLogs(){if(t.isNode&&this.fs)try{this.fs.writeFileSync(this.filename,"","utf8")}catch(e){console.error("FileLogHandler: Failed to clear file:",e)}else if(t.isBrowser){const e=`logger_${this.filename}`;localStorage.removeItem(e)}}},exports.FileTransport=class{name="file";buffer=[];flushTimer;options;constructor(e){this.options=e||{},this.options.flushInterval&&(this.flushTimer=setInterval(()=>this.flush(),this.options.flushInterval))}write(e){const t=JSON.stringify(e)+"\n";this.buffer.push(t),this.buffer.length>=(this.options.batchSize||100)&&this.flush()}async flush(){if(0===this.buffer.length)return;const e=this.buffer.join("");if(this.buffer=[],void 0!==globalThis.process&&"function"==typeof require)try{const t=require("fs"),s=this.options.destination||"app.log";t.appendFileSync(s,e)}catch{}}close(){this.flushTimer&&clearInterval(this.flushTimer),this.flush()}},exports.HttpTransport=class{name="http";buffer=[];flushTimer;options;constructor(e){this.options=e||{},this.options.flushInterval&&(this.flushTimer=setInterval(()=>this.flush(),this.options.flushInterval))}write(e){this.buffer.push(e),this.buffer.length>=(this.options.batchSize||50)&&this.flush()}async flush(){if(0===this.buffer.length||!this.options.url)return;const e=[...this.buffer];this.buffer=[];try{await fetch(this.options.url,{method:"POST",headers:{"Content-Type":"application/json",...this.options.headers},body:JSON.stringify({logs:e})})}catch{this.buffer.unshift(...e)}}close(){this.flushTimer&&clearInterval(this.flushTimer),this.flush()}},exports.StyleCache=StyleCache,exports.addHandler=e=>getLogger().addHandler(e),exports.addSerializer=(e,t,s)=>getLogger().addSerializer(e,t,s),exports.addTransport=e=>getLogger().addTransport(e),exports.api=e=>getLogger().api(e),exports.badge=e=>getLogger().badge(e),exports.badges=e=>getLogger().badges(e),exports.clearBadges=()=>getLogger().clearBadges(),exports.cli=e=>getLogger().cli(e),exports.closeTransports=()=>getLogger().closeTransports(),exports.component=e=>getLogger().component(e),exports.createStyle=()=>new t.StyleBuilder,exports.critical=(...e)=>getLogger().critical(...e),exports.debug=(...e)=>getLogger().debug(...e),exports.default=a,exports.error=(...e)=>getLogger().error(...e),exports.flushTransports=()=>getLogger().flushTransports(),exports.getStyleCache=function(){return i||(i=new StyleCache),i},exports.group=(e,t)=>getLogger().group(e,t),exports.groupEnd=()=>getLogger().groupEnd(),exports.info=(...e)=>getLogger().info(...e),exports.logAnimated=(e,t)=>getLogger().logAnimated(e,t),exports.logWithSVG=(e,t,s)=>getLogger().logWithSVG(e,t,s),exports.off=(e,t)=>getLogger().off(e,t),exports.on=(e,t,s)=>getLogger().on(e,t,s),exports.once=(e,t,s)=>getLogger().once(e,t,s),exports.removeSerializer=e=>getLogger().removeSerializer(e),exports.removeTransport=e=>getLogger().removeTransport(e),exports.scope=e=>getLogger().scope(e),exports.setBannerType=e=>getLogger().setBannerType(e),exports.setGlobalPrefix=e=>getLogger().setGlobalPrefix(e),exports.setTheme=e=>getLogger().setTheme(e),exports.setVerbosity=e=>getLogger().setVerbosity(e),exports.showBanner=e=>getLogger().showBanner(e),exports.stylePresets=l,exports.success=(...e)=>getLogger().success(...e),exports.table=(e,t)=>getLogger().table(e,t),exports.time=e=>getLogger().time(e),exports.timeEnd=e=>getLogger().timeEnd(e),exports.trace=(...e)=>getLogger().trace(...e),exports.use=(e,t)=>getLogger().use(e,t),exports.warn=(...e)=>getLogger().warn(...e);
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./chunks/Logger-D7cfaz15.js"),t=require("./chunks/environment-C_8J-zQ_.js"),r=require("./chunks/formatting-Cg5YhB9Y.js"),s=require("./chunks/RemoteLogHandler-ymkQ97xl.js"),o={maxEntries:100,ttl:3e5,enabled:!0};class StyleCache{cache=/* @__PURE__ */new Map;config;hitCount=0;missCount=0;constructor(e={}){this.config={...o,...e}}generateKey(e){return`${e.level}:${e.theme}:${e.presetName||"default"}:${e.hasPrefix}:${e.hasLocation}`}get(e){if(!this.config.enabled)return null;const t=this.generateKey(e),r=this.cache.get(t);return r?Date.now()-r.createdAt>this.config.ttl?(this.cache.delete(t),this.missCount++,null):(r.hits++,this.cache.delete(t),this.cache.set(t,r),this.hitCount++,r):(this.missCount++,null)}set(e,t,r){if(!this.config.enabled)return;const s=this.generateKey(e);if(this.cache.size>=this.config.maxEntries){const e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(s,{format:t,styles:[...r],createdAt:Date.now(),hits:0})}clear(){this.cache.clear(),this.hitCount=0,this.missCount=0}getStats(){const e=this.hitCount+this.missCount;return{size:this.cache.size,maxSize:this.config.maxEntries,hitRate:e>0?this.hitCount/e:0,hits:this.hitCount,misses:this.missCount}}setEnabled(e){this.config.enabled=e,e||this.clear()}isEnabled(){return this.config.enabled}}let i=null,n=null;function getLogger(){return n||(n=new e.Logger),n}const a=getLogger(),l={success:t.StylePresets.success().build(),error:t.StylePresets.error().build(),warning:t.StylePresets.warning().build(),info:t.StylePresets.info().build(),accent:t.StylePresets.accent().build()};exports.APILogger=e.APILogger,exports.BANNER_VARIANTS=e.BANNER_VARIANTS,exports.ComponentLogger=e.ComponentLogger,exports.ContextLogger=e.ContextLogger,exports.HookManager=e.HookManager,exports.Logger=e.Logger,exports.ScopedLogger=e.ScopedLogger,exports.SerializerRegistry=e.SerializerRegistry,exports.THEME_BANNERS=e.THEME_BANNERS,exports.THEME_PRESETS=e.THEME_PRESETS,exports.TransportManager=e.TransportManager,exports.applyLogOptions=e.applyLogOptions,exports.formatBadge=e.formatBadge,exports.formatColumns=e.formatColumns,exports.formatElapsedTime=e.formatElapsedTime,exports.formatKeyValue=e.formatKeyValue,exports.formatRelativeTime=e.formatRelativeTime,exports.formatTimestampExt=e.formatTimestamp,exports.formatWithRightAlign=e.formatWithRightAlign,exports.getVisibleLength=e.getVisibleLength,exports.isKeyValueObject=e.isKeyValueObject,exports.padToWidth=e.padToWidth,exports.resetStartTime=e.resetStartTime,exports.stripAnsi=e.stripAnsi,exports.ANSI=t.ANSI,exports.BUILD_PRESETS=t.BUILD_PRESETS,exports.DEFAULT_CONFIG=t.DEFAULT_CONFIG,exports.ENVIRONMENT_DETECTION=t.ENVIRONMENT_DETECTION,exports.StyleBuilder=t.StyleBuilder,exports.StylePresets=t.StylePresets,exports.TerminalRenderer=t.TerminalRenderer,exports.colorToHex=t.colorToHex,exports.cssColorToANSI=t.cssColorToANSI,exports.detectEnvironmentPreset=t.detectEnvironmentPreset,exports.formatTimestamp=t.formatTimestamp,exports.getANSI256Background=t.getANSI256Background,exports.getANSI256Foreground=t.getANSI256Foreground,exports.getANSIBackground=t.getANSIBackground,exports.getANSIForeground=t.getANSIForeground,exports.getColorCapability=t.getColorCapability,exports.getEnvironment=t.getEnvironment,exports.getEnvironmentInfo=t.getEnvironmentInfo,exports.getOptimalConfig=t.getOptimalConfig,exports.getTerminalHeight=t.getTerminalHeight,exports.getTerminalWidth=t.getTerminalWidth,exports.hexTo256=t.hexTo256,exports.hexToRgb=t.hexToRgb,exports.isRunningInTerminal=t.isRunningInTerminal,exports.parseStackTrace=t.parseStackTrace,exports.rgbToHex=t.rgbToHex,exports.supportsANSI=t.supportsANSI,exports.BUILD_FORMATTERS=r.BUILD_FORMATTERS,exports.ansiBackground=r.ansiBackground,exports.ansiBold=r.ansiBold,exports.ansiColor=r.ansiColor,exports.ansiDim=r.ansiDim,exports.ansiStyle=r.ansiStyle,exports.ansiUnderline=r.ansiUnderline,exports.createANSIOutput=r.createANSIOutput,exports.createBuildOutput=r.createBuildOutput,exports.createCIOutput=r.createCIOutput,exports.createOutput=r.createOutput,exports.detectOptimalFormat=r.detectOptimalFormat,exports.formatLogLevelANSI=r.formatLogLevelANSI,exports.formatSuccessANSI=r.formatSuccessANSI,exports.sanitizeEmojis=r.sanitizeEmojis,exports.RemoteLogHandler=s.RemoteLogHandler,exports.AnalyticsLogHandler=class{handle(e,t,r,s){"error"!==e&&"critical"!==e||s.timestamp}},exports.BufferWriter=class{buffer=[];maxSize;constructor(e=1e3){this.maxSize=e}write(e,t,r){this.buffer.length>=this.maxSize&&this.buffer.shift(),this.buffer.push({message:e,level:t,styles:r,timestamp:Date.now()})}getBuffer(){return[...this.buffer]}getByLevel(...e){return this.buffer.filter(t=>e.includes(t.level))}get size(){return this.buffer.length}get isEmpty(){return 0===this.buffer.length}clear(){this.buffer=[]}flush(){this.buffer.forEach(e=>{e.styles.length>0?console.log(e.message,...e.styles):console.log(e.message)}),this.clear()}replay(){this.buffer.forEach(e=>{e.styles.length>0?console.log(e.message,...e.styles):console.log(e.message)})}toArray(){return this.buffer.map(e=>e.message)}toString(e="\n"){return this.toArray().join(e)}},exports.ConsoleTransport=class{constructor(e){this.options=e}name="console";write(e){const t=this.getConsoleMethod(e.level),r=e.prefix?`[${e.prefix}] `:"",s=e.location?` (${e.location.file}:${e.location.line})`:"";console[t](`[${e.level.toUpperCase()}]${r} ${e.msg}${s}`)}getConsoleMethod(e){switch(e){case"debug":default:return"log";case"info":return"info";case"warn":return"warn";case"error":case"critical":return"error"}}},exports.FileLogHandler=class{filename;maxSize;fs;constructor(e="app.log",r){if(this.filename=e,this.maxSize=r,t.isNode)try{this.fs=require("fs")}catch(s){console.warn("FileLogHandler: Unable to load fs module:",s)}}handle(e,s,o,i){const n={timestamp:i.timestamp,level:e.toUpperCase(),prefix:i.prefix,message:s,args:o.slice(1).map(e=>r.safeSerialize(e)),location:i.stackInfo},a=this.formatLogLine(n);t.isNode&&this.fs?this.writeToFileNode(a):t.isBrowser?this.writeToFileLocal(a):console.log(`[FILE-LOG] ${a}`)}formatLogLine(e){let t=[e.timestamp,`[${e.level}]`,e.prefix?`[${e.prefix}]`:"",e.message].filter(Boolean).join(" ");return e.args&&e.args.length>0&&(t+=" "+e.args.map(e=>"object"==typeof e?JSON.stringify(e):String(e)).join(" ")),e.location&&(t+=` (${e.location.file}:${e.location.line}:${e.location.column})`),t}writeToFileNode(e){if(this.fs)try{if(this.maxSize)try{if(this.fs.statSync(this.filename).size>this.maxSize){const e=`${this.filename}.bak`;this.fs.renameSync(this.filename,e)}}catch(t){}this.fs.appendFileSync(this.filename,e+"\n","utf8")}catch(t){console.error("FileLogHandler: Failed to write to file:",t)}}writeToFileLocal(e){try{const t=`logger_${this.filename}`,r=localStorage.getItem(t)||"";let s=r;if(r.length>0&&(s+="\n"),s+=e,this.maxSize||s.split("\n").length>1e3){const e=s.split("\n"),t=this.maxSize?Math.floor(this.maxSize/100):1e3;e.length>t&&(s=e.slice(-t).join("\n"))}localStorage.setItem(t,s)}catch(t){console.error("FileLogHandler: Failed to write to localStorage:",t)}}getLogs(){if(t.isNode&&this.fs)try{return this.fs.readFileSync(this.filename,"utf8")}catch(e){return null}else if(t.isBrowser){const e=`logger_${this.filename}`;return localStorage.getItem(e)}return null}clearLogs(){if(t.isNode&&this.fs)try{this.fs.writeFileSync(this.filename,"","utf8")}catch(e){console.error("FileLogHandler: Failed to clear file:",e)}else if(t.isBrowser){const e=`logger_${this.filename}`;localStorage.removeItem(e)}}},exports.FileTransport=class{name="file";buffer=[];flushTimer;options;constructor(e){this.options=e||{},this.options.flushInterval&&(this.flushTimer=setInterval(()=>this.flush(),this.options.flushInterval))}write(e){const t=JSON.stringify(e)+"\n";this.buffer.push(t),this.buffer.length>=(this.options.batchSize||100)&&this.flush()}async flush(){if(0===this.buffer.length)return;const e=this.buffer.join("");if(this.buffer=[],void 0!==globalThis.process&&"function"==typeof require)try{const t=require("fs"),r=this.options.destination||"app.log";t.appendFileSync(r,e)}catch{}}close(){this.flushTimer&&clearInterval(this.flushTimer),this.flush()}},exports.HttpTransport=class{name="http";buffer=[];flushTimer;options;constructor(e){this.options=e||{},this.options.flushInterval&&(this.flushTimer=setInterval(()=>this.flush(),this.options.flushInterval))}write(e){this.buffer.push(e),this.buffer.length>=(this.options.batchSize||50)&&this.flush()}async flush(){if(0===this.buffer.length||!this.options.url)return;const e=[...this.buffer];this.buffer=[];try{await fetch(this.options.url,{method:"POST",headers:{"Content-Type":"application/json",...this.options.headers},body:JSON.stringify({logs:e})})}catch{this.buffer.unshift(...e)}}close(){this.flushTimer&&clearInterval(this.flushTimer),this.flush()}},exports.StyleCache=StyleCache,exports.addHandler=e=>getLogger().addHandler(e),exports.addSerializer=(e,t,r)=>getLogger().addSerializer(e,t,r),exports.addTransport=e=>getLogger().addTransport(e),exports.api=e=>getLogger().api(e),exports.badge=e=>getLogger().badge(e),exports.badges=e=>getLogger().badges(e),exports.clearBadges=()=>getLogger().clearBadges(),exports.cli=e=>getLogger().cli(e),exports.closeTransports=()=>getLogger().closeTransports(),exports.component=e=>getLogger().component(e),exports.createStyle=()=>new t.StyleBuilder,exports.critical=(...e)=>getLogger().critical(...e),exports.debug=(...e)=>getLogger().debug(...e),exports.default=a,exports.error=(...e)=>getLogger().error(...e),exports.flushTransports=()=>getLogger().flushTransports(),exports.getStyleCache=function(){return i||(i=new StyleCache),i},exports.group=(e,t)=>getLogger().group(e,t),exports.groupEnd=()=>getLogger().groupEnd(),exports.info=(...e)=>getLogger().info(...e),exports.logAnimated=(e,t)=>getLogger().logAnimated(e,t),exports.logWithSVG=(e,t,r)=>getLogger().logWithSVG(e,t,r),exports.off=(e,t)=>getLogger().off(e,t),exports.on=(e,t,r)=>getLogger().on(e,t,r),exports.once=(e,t,r)=>getLogger().once(e,t,r),exports.removeSerializer=e=>getLogger().removeSerializer(e),exports.removeTransport=e=>getLogger().removeTransport(e),exports.scope=e=>getLogger().scope(e),exports.setBannerType=e=>getLogger().setBannerType(e),exports.setGlobalPrefix=e=>getLogger().setGlobalPrefix(e),exports.setTheme=e=>getLogger().setTheme(e),exports.setVerbosity=e=>getLogger().setVerbosity(e),exports.showBanner=e=>getLogger().showBanner(e),exports.stylePresets=l,exports.success=(...e)=>getLogger().success(...e),exports.table=(e,t)=>getLogger().table(e,t),exports.time=e=>getLogger().time(e),exports.timeEnd=e=>getLogger().timeEnd(e),exports.trace=(...e)=>getLogger().trace(...e),exports.use=(e,t)=>getLogger().use(e,t),exports.warn=(...e)=>getLogger().warn(...e);
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/styling/StyleCache.ts","../src/index.ts","../src/handlers/AnalyticsLogHandler.ts","../src/transports/ConsoleTransport.ts","../src/handlers/FileLogHandler.ts","../src/transports/FileTransport.ts","../src/transports/HttpTransport.ts"],"sourcesContent":["import type { LogLevel, DevToolsTheme } from '../types/core.js';\n\ninterface CacheKey {\n level: LogLevel | 'success';\n theme: DevToolsTheme;\n presetName?: string;\n hasPrefix: boolean;\n hasLocation: boolean;\n}\n\ninterface CacheEntry {\n styles: string[];\n format: string;\n createdAt: number;\n hits: number;\n}\n\nexport interface StyleCacheConfig {\n maxEntries?: number;\n ttl?: number;\n enabled?: boolean;\n}\n\nconst DEFAULT_CONFIG: Required<StyleCacheConfig> = {\n maxEntries: 100,\n ttl: 5 * 60 * 1000,\n enabled: true\n};\n\nexport class StyleCache {\n private cache: Map<string, CacheEntry> = new Map();\n private config: Required<StyleCacheConfig>;\n private hitCount = 0;\n private missCount = 0;\n\n constructor(config: StyleCacheConfig = {}) {\n this.config = { ...DEFAULT_CONFIG, ...config };\n }\n\n private generateKey(key: CacheKey): string {\n return `${key.level}:${key.theme}:${key.presetName || 'default'}:${key.hasPrefix}:${key.hasLocation}`;\n }\n\n get(key: CacheKey): CacheEntry | null {\n if (!this.config.enabled) return null;\n\n const cacheKey = this.generateKey(key);\n const entry = this.cache.get(cacheKey);\n\n if (!entry) {\n this.missCount++;\n return null;\n }\n\n if (Date.now() - entry.createdAt > this.config.ttl) {\n this.cache.delete(cacheKey);\n this.missCount++;\n return null;\n }\n\n entry.hits++;\n this.cache.delete(cacheKey);\n this.cache.set(cacheKey, entry);\n this.hitCount++;\n\n return entry;\n }\n\n set(key: CacheKey, format: string, styles: string[]): void {\n if (!this.config.enabled) return;\n\n const cacheKey = this.generateKey(key);\n\n if (this.cache.size >= this.config.maxEntries) {\n const firstKey = this.cache.keys().next().value;\n if (firstKey) {\n this.cache.delete(firstKey);\n }\n }\n\n this.cache.set(cacheKey, {\n format,\n styles: [...styles],\n createdAt: Date.now(),\n hits: 0\n });\n }\n\n clear(): void {\n this.cache.clear();\n this.hitCount = 0;\n this.missCount = 0;\n }\n\n getStats(): {\n size: number;\n maxSize: number;\n hitRate: number;\n hits: number;\n misses: number;\n } {\n const total = this.hitCount + this.missCount;\n return {\n size: this.cache.size,\n maxSize: this.config.maxEntries,\n hitRate: total > 0 ? this.hitCount / total : 0,\n hits: this.hitCount,\n misses: this.missCount\n };\n }\n\n setEnabled(enabled: boolean): void {\n this.config.enabled = enabled;\n if (!enabled) {\n this.clear();\n }\n }\n\n isEnabled(): boolean {\n return this.config.enabled;\n }\n}\n\nlet _styleCache: StyleCache | null = null;\n\nexport function getStyleCache(): StyleCache {\n if (!_styleCache) {\n _styleCache = new StyleCache();\n }\n return _styleCache;\n}\n","/**\n * @fileoverview Better Logger - Librería completa con todas las características\n * @version 0.3.0\n * @since 2024\n * \n * Punto de entrada principal que proporciona la experiencia completa de Better Logger\n * con características avanzadas incluyendo estilos CSS, soporte SVG, animaciones,\n * capacidades de exportación y logging remoto.\n * \n * @module @mks2508/better-logger\n */\n\n// Main Logger class with all features\nimport { Logger } from './Logger.js';\nimport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler\n} from './types/index.js';\n\n// Lazy singleton - se inicializa solo cuando se necesita\nlet _logger: Logger | null = null;\n\nfunction getLogger(): Logger {\n if (!_logger) {\n _logger = new Logger();\n }\n return _logger;\n}\n\n/**\n * Clase principal Logger con conjunto completo de características\n * \n * @example\n * // Importación y uso básico\n * import { Logger } from '@mks2508/better-logger';\n * \n * const logger = new Logger();\n * logger.preset('cyberpunk'); // Aplicar preset completo\n * logger.info('¡Hola mundo!');\n * \n * @example\n * // Logger con scope para componentes\n * const auth = logger.component('Auth');\n * auth.info('Usuario autenticando...');\n * auth.success('Login exitoso');\n * \n * @example\n * // Logger para APIs con badges\n * const api = logger.api('GraphQL');\n * api.badges(['v2', 'cached']).info('Query ejecutada');\n * \n * @since 0.3.0\n */\nexport { Logger };\n\n/**\n * Instancia singleton del logger lista para usar\n * @default\n * \n * @example\n * // Uso directo sin crear instancia\n * import logger from '@mks2508/better-logger';\n * \n * logger.info('Aplicación iniciada');\n * logger.success('Conexión establecida');\n * logger.warn('Memoria al 80%');\n * logger.error('Fallo en conexión');\n */\nexport default getLogger();\n\n/**\n * Métodos de logging individuales (enlazados al singleton)\n * \n * @example\n * // Importar solo los métodos necesarios\n * import { info, error, success } from '@mks2508/better-logger';\n * \n * info('Proceso iniciado');\n * success('✓ Completado exitosamente');\n * error('Error:', errorDetails);\n * \n * @since 0.3.0\n */\nexport const debug = (...args: any[]) => getLogger().debug(...args);\nexport const info = (...args: any[]) => getLogger().info(...args);\nexport const warn = (...args: any[]) => getLogger().warn(...args);\nexport const error = (...args: any[]) => getLogger().error(...args);\nexport const success = (...args: any[]) => getLogger().success(...args);\nexport const critical = (...args: any[]) => getLogger().critical(...args);\nexport const trace = (...args: any[]) => getLogger().trace(...args);\nexport const table = (data: any, columns?: string[]) => getLogger().table(data, columns);\nexport const group = (label: string, collapsed?: boolean) => getLogger().group(label, collapsed);\nexport const groupEnd = () => getLogger().groupEnd();\nexport const time = (label: string) => getLogger().time(label);\nexport const timeEnd = (label: string) => getLogger().timeEnd(label);\nexport const setGlobalPrefix = (prefix: string) => getLogger().setGlobalPrefix(prefix);\nexport const scope = (name: string) => getLogger().scope(name);\nexport const component = (name: string) => getLogger().component(name);\nexport const api = (name: string) => getLogger().api(name);\nexport const badges = (badgeList: string[]) => getLogger().badges(badgeList);\nexport const badge = (badgeName: string) => getLogger().badge(badgeName);\nexport const clearBadges = () => getLogger().clearBadges();\nexport const setVerbosity = (level: Verbosity) => getLogger().setVerbosity(level);\nexport const addHandler = (handler: ILogHandler) => getLogger().addHandler(handler);\nexport const setTheme = (theme: ThemeVariant) => getLogger().setTheme(theme);\nexport const setBannerType = (bannerType: BannerType) => getLogger().setBannerType(bannerType);\nexport const showBanner = (bannerType?: BannerType) => getLogger().showBanner(bannerType);\nexport const logWithSVG = (message: string, svgContent?: string, options?: StyleOptions) => \n getLogger().logWithSVG(message, svgContent, options);\nexport const logAnimated = (message: string, duration?: number) => \n getLogger().logAnimated(message, duration);\nexport const cli = (command: string) => getLogger().cli(command);\n\n// Type exports\nexport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler,\n LoggerConfig,\n LogMetadata,\n StackInfo,\n TimerEntry,\n TimerResult,\n OutputFormat,\n IScopedLogger,\n IAPILogger,\n IComponentLogger,\n Bindings,\n SerializerFn,\n SerializerContext,\n SerializerConfig,\n ISerializerRegistry,\n HookLogEntry,\n HookEvent,\n HookCallback,\n MiddlewareFn,\n IHookManager,\n TransportRecord,\n TransportOptions,\n TransportTarget,\n ITransport,\n StyleCacheConfig\n} from './types/index.js';\n\n// Styling utilities\nexport { \n StyleBuilder,\n StylePresets,\n THEME_PRESETS,\n THEME_BANNERS,\n BANNER_VARIANTS\n} from './styling/index.js';\n\n// Handler exports\nexport {\n FileLogHandler,\n RemoteLogHandler,\n AnalyticsLogHandler\n} from './handlers/index.js';\n\n// Serializers\nexport { SerializerRegistry } from './serializers/index.js';\n\n// Hooks & Middleware\nexport { HookManager } from './hooks/index.js';\n\n// Transports\nexport {\n TransportManager,\n ConsoleTransport,\n FileTransport,\n HttpTransport\n} from './transports/index.js';\n\n// Style Cache\nexport { StyleCache, getStyleCache } from './styling/StyleCache.js';\n\n// Enterprise feature function exports\nimport type { SerializerFn, HookEvent, HookCallback, MiddlewareFn, TransportTarget } from './types/index.js';\nexport const addSerializer = <T>(\n type: new (...args: any[]) => T,\n serializer: SerializerFn<T>,\n priority?: number\n) => getLogger().addSerializer(type, serializer, priority);\nexport const removeSerializer = <T>(type: new (...args: any[]) => T) =>\n getLogger().removeSerializer(type);\nexport const on = (event: HookEvent, callback: HookCallback, priority?: number) =>\n getLogger().on(event, callback, priority);\nexport const once = (event: HookEvent, callback: HookCallback, priority?: number) =>\n getLogger().once(event, callback, priority);\nexport const off = (event: HookEvent, callback: HookCallback) =>\n getLogger().off(event, callback);\nexport const use = (middleware: MiddlewareFn, priority?: number) =>\n getLogger().use(middleware, priority);\nexport const addTransport = (target: TransportTarget) =>\n getLogger().addTransport(target);\nexport const removeTransport = (id: string) =>\n getLogger().removeTransport(id);\nexport const flushTransports = () =>\n getLogger().flushTransports();\nexport const closeTransports = () =>\n getLogger().closeTransports();\n\n// Scoped loggers\nexport {\n ScopedLogger,\n APILogger,\n ComponentLogger,\n ContextLogger\n} from './ScopedLogger.js';\n\n// Constants\nexport { DEFAULT_CONFIG } from './constants.js';\n\n// Utility exports\nexport {\n parseStackTrace,\n formatTimestamp,\n detectOptimalFormat,\n createOutput,\n createANSIOutput,\n createBuildOutput,\n createCIOutput\n} from './utils/index.js';\n\n// ANSI color utilities\nexport {\n ansiStyle,\n ansiColor,\n ansiBackground,\n ansiBold,\n ansiDim,\n ansiUnderline,\n formatLogLevelANSI,\n formatSuccessANSI,\n BUILD_FORMATTERS,\n sanitizeEmojis\n} from './utils/ansi-colors.js';\n\n// Environment detection and presets\nexport {\n BUILD_PRESETS,\n ENVIRONMENT_DETECTION,\n detectEnvironmentPreset,\n getOptimalConfig\n} from './constants.js';\n\n/**\n * Utilidades de estilo para crear estilos personalizados de consola\n * \n * @example\n * // Crear estilo personalizado\n * import { createStyle, stylePresets } from '@mks2508/better-logger';\n * \n * const miEstilo = createStyle()\n * .bg('linear-gradient(45deg, #ff6b6b, #feca57)')\n * .color('white')\n * .padding('10px')\n * .rounded('8px')\n * .bold()\n * .build();\n * \n * console.log('%cMensaje estilizado', miEstilo);\n * \n * @example\n * // Usar presets predefinidos\n * console.log('%cÉxito!', stylePresets.success);\n * console.log('%cError!', stylePresets.error);\n * \n * @since 0.3.0\n */\nimport { StyleBuilder, StylePresets } from './styling/index.js';\n\n/**\n * Crea una nueva instancia de StyleBuilder para estilos personalizados de consola\n * \n * @returns {StyleBuilder} Constructor de estilos encadenable\n * \n * @example\n * const estilo = createStyle()\n * .gradient('#667eea', '#764ba2')\n * .color('white')\n * .padding('8px 16px')\n * .rounded('4px')\n * .shadow('0 2px 4px rgba(0,0,0,0.2)')\n * .build();\n * \n * @since 0.3.0\n */\nexport const createStyle = () => new StyleBuilder();\n\n/**\n * Presets de estilo predefinidos para casos de uso comunes\n * \n * @constant {Object} stylePresets\n * \n * @example\n * console.log('%cOperación exitosa', stylePresets.success);\n * console.log('%cAdvertencia', stylePresets.warning);\n * console.log('%cError crítico', stylePresets.error);\n * console.log('%cInformación', stylePresets.info);\n * console.log('%cDestacado', stylePresets.accent);\n * \n * @since 0.3.0\n */\nexport const stylePresets = {\n success: StylePresets.success().build(),\n error: StylePresets.error().build(),\n warning: StylePresets.warning().build(),\n info: StylePresets.info().build(),\n accent: StylePresets.accent().build(),\n};","/**\n * @fileoverview Analytics log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\n\n/**\n * Example custom handler for analytics demonstration\n */\nexport class AnalyticsLogHandler implements ILogHandler {\n handle(level: LogLevel, message: string, _args: any[], metadata: LogMetadata): void {\n // In a real implementation, this could send analytics data\n if (level === 'error' || level === 'critical') {\n // Track errors for analytics\n console.debug('Analytics: Error tracked', { \n level, \n message, \n timestamp: metadata.timestamp \n });\n }\n }\n}","import type { TransportRecord, TransportOptions, ITransport, LogLevel } from '../types/index.js';\n\nexport class ConsoleTransport implements ITransport {\n readonly name = 'console';\n\n constructor(private options?: TransportOptions) {}\n\n write(record: TransportRecord): void {\n const method = this.getConsoleMethod(record.level);\n const prefix = record.prefix ? `[${record.prefix}] ` : '';\n const location = record.location\n ? ` (${record.location.file}:${record.location.line})`\n : '';\n\n console[method](`[${record.level.toUpperCase()}]${prefix} ${record.msg}${location}`);\n }\n\n private getConsoleMethod(level: LogLevel): 'log' | 'info' | 'warn' | 'error' {\n switch (level) {\n case 'debug': return 'log';\n case 'info': return 'info';\n case 'warn': return 'warn';\n case 'error':\n case 'critical': return 'error';\n default: return 'log';\n }\n }\n}\n","/**\n * @fileoverview File-based log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\nimport { isNode, isBrowser } from '../utils/environment.js';\nimport { safeSerialize } from '../utils/formatting.js';\n\n/**\n * Universal file-based log handler for persistent logging\n * Works in both Node.js (real files) and browser (localStorage)\n */\nexport class FileLogHandler implements ILogHandler {\n private filename: string;\n private maxSize?: number;\n private fs?: any; // Node.js fs module\n\n constructor(filename: string = 'app.log', maxSize?: number) {\n this.filename = filename;\n this.maxSize = maxSize;\n \n // Load Node.js fs module if in Node environment\n if (isNode) {\n try {\n this.fs = require('fs');\n } catch (error) {\n console.warn('FileLogHandler: Unable to load fs module:', error);\n }\n }\n }\n\n handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): void {\n const logEntry = {\n timestamp: metadata.timestamp,\n level: level.toUpperCase(),\n prefix: metadata.prefix,\n message,\n args: args.slice(1).map(arg => safeSerialize(arg)),\n location: metadata.stackInfo,\n };\n\n const logLine = this.formatLogLine(logEntry);\n\n if (isNode && this.fs) {\n this.writeToFileNode(logLine);\n } else if (isBrowser) {\n this.writeToFileLocal(logLine);\n } else {\n // Fallback - just console output\n console.log(`[FILE-LOG] ${logLine}`);\n }\n }\n\n /**\n * Format log entry as a single line for file storage\n */\n private formatLogLine(entry: any): string {\n const parts = [\n entry.timestamp,\n `[${entry.level}]`,\n entry.prefix ? `[${entry.prefix}]` : '',\n entry.message\n ].filter(Boolean);\n\n let line = parts.join(' ');\n \n if (entry.args && entry.args.length > 0) {\n line += ' ' + entry.args.map((arg: any) => \n typeof arg === 'object' ? JSON.stringify(arg) : String(arg)\n ).join(' ');\n }\n \n if (entry.location) {\n line += ` (${entry.location.file}:${entry.location.line}:${entry.location.column})`;\n }\n \n return line;\n }\n\n /**\n * Write to actual file in Node.js environment\n */\n private writeToFileNode(logLine: string): void {\n if (!this.fs) return;\n\n try {\n // Check file size if maxSize is set\n if (this.maxSize) {\n try {\n const stats = this.fs.statSync(this.filename);\n if (stats.size > this.maxSize) {\n // Simple rotation: backup current file and start fresh\n const backupName = `${this.filename}.bak`;\n this.fs.renameSync(this.filename, backupName);\n }\n } catch (error) {\n // File doesn't exist yet, that's fine\n }\n }\n\n // Append to file\n this.fs.appendFileSync(this.filename, logLine + '\\n', 'utf8');\n } catch (error) {\n console.error('FileLogHandler: Failed to write to file:', error);\n }\n }\n\n /**\n * Write to localStorage in browser environment\n */\n private writeToFileLocal(logLine: string): void {\n try {\n const storageKey = `logger_${this.filename}`;\n const existingLogs = localStorage.getItem(storageKey) || '';\n \n let newLogs = existingLogs;\n if (existingLogs.length > 0) {\n newLogs += '\\n';\n }\n newLogs += logLine;\n \n // Simple size management - keep last 1000 lines max\n if (this.maxSize || newLogs.split('\\n').length > 1000) {\n const lines = newLogs.split('\\n');\n const maxLines = this.maxSize ? Math.floor(this.maxSize / 100) : 1000;\n if (lines.length > maxLines) {\n newLogs = lines.slice(-maxLines).join('\\n');\n }\n }\n \n localStorage.setItem(storageKey, newLogs);\n } catch (error) {\n console.error('FileLogHandler: Failed to write to localStorage:', error);\n }\n }\n\n /**\n * Get stored logs (useful for debugging)\n */\n getLogs(): string | null {\n if (isNode && this.fs) {\n try {\n return this.fs.readFileSync(this.filename, 'utf8');\n } catch (error) {\n return null;\n }\n } else if (isBrowser) {\n const storageKey = `logger_${this.filename}`;\n return localStorage.getItem(storageKey);\n }\n return null;\n }\n\n /**\n * Clear stored logs\n */\n clearLogs(): void {\n if (isNode && this.fs) {\n try {\n this.fs.writeFileSync(this.filename, '', 'utf8');\n } catch (error) {\n console.error('FileLogHandler: Failed to clear file:', error);\n }\n } else if (isBrowser) {\n const storageKey = `logger_${this.filename}`;\n localStorage.removeItem(storageKey);\n }\n }\n}","import type { TransportRecord, TransportOptions, ITransport } from '../types/index.js';\n\nexport interface FileTransportOptions extends TransportOptions {\n destination?: string;\n}\n\nexport class FileTransport implements ITransport {\n readonly name = 'file';\n private buffer: string[] = [];\n private flushTimer?: ReturnType<typeof setInterval>;\n private options: FileTransportOptions;\n\n constructor(options?: FileTransportOptions) {\n this.options = options || {};\n\n if (this.options.flushInterval) {\n this.flushTimer = setInterval(() => this.flush(), this.options.flushInterval);\n }\n }\n\n write(record: TransportRecord): void {\n const line = JSON.stringify(record) + '\\n';\n this.buffer.push(line);\n\n if (this.buffer.length >= (this.options.batchSize || 100)) {\n this.flush();\n }\n }\n\n async flush(): Promise<void> {\n if (this.buffer.length === 0) return;\n\n const lines = this.buffer.join('');\n this.buffer = [];\n\n if (typeof globalThis.process !== 'undefined' && typeof require === 'function') {\n try {\n const fs = require('fs');\n const dest = this.options.destination || 'app.log';\n fs.appendFileSync(dest, lines);\n } catch {\n // Silent fail in browser or if fs not available\n }\n }\n }\n\n close(): void {\n if (this.flushTimer) {\n clearInterval(this.flushTimer);\n }\n this.flush();\n }\n}\n","import type { TransportRecord, TransportOptions, ITransport } from '../types/index.js';\n\nexport interface HttpTransportOptions extends TransportOptions {\n url?: string;\n headers?: Record<string, string>;\n}\n\nexport class HttpTransport implements ITransport {\n readonly name = 'http';\n private buffer: TransportRecord[] = [];\n private flushTimer?: ReturnType<typeof setInterval>;\n private options: HttpTransportOptions;\n\n constructor(options?: HttpTransportOptions) {\n this.options = options || {};\n\n if (this.options.flushInterval) {\n this.flushTimer = setInterval(() => this.flush(), this.options.flushInterval);\n }\n }\n\n write(record: TransportRecord): void {\n this.buffer.push(record);\n\n if (this.buffer.length >= (this.options.batchSize || 50)) {\n this.flush();\n }\n }\n\n async flush(): Promise<void> {\n if (this.buffer.length === 0 || !this.options.url) return;\n\n const records = [...this.buffer];\n this.buffer = [];\n\n try {\n await fetch(this.options.url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...this.options.headers\n },\n body: JSON.stringify({ logs: records })\n });\n } catch {\n this.buffer.unshift(...records);\n }\n }\n\n close(): void {\n if (this.flushTimer) {\n clearInterval(this.flushTimer);\n }\n this.flush();\n }\n}\n"],"names":["DEFAULT_CONFIG","maxEntries","ttl","enabled","StyleCache","cache","Map","config","hitCount","missCount","constructor","this","generateKey","key","level","theme","presetName","hasPrefix","hasLocation","get","cacheKey","entry","Date","now","createdAt","delete","hits","set","format","styles","size","firstKey","keys","next","value","clear","getStats","total","maxSize","hitRate","misses","setEnabled","isEnabled","_styleCache","_logger","getLogger","Logger","index","stylePresets","success","StylePresets","build","error","warning","info","accent","handle","message","_args","metadata","timestamp","options","name","write","record","method","getConsoleMethod","prefix","location","file","line","console","toUpperCase","msg","filename","fs","isNode","require","warn","args","logEntry","slice","map","arg","safeSerialize","stackInfo","logLine","formatLogLine","writeToFileNode","isBrowser","writeToFileLocal","log","filter","Boolean","join","length","JSON","stringify","String","column","statSync","backupName","renameSync","appendFileSync","storageKey","existingLogs","localStorage","getItem","newLogs","split","lines","maxLines","Math","floor","setItem","getLogs","readFileSync","clearLogs","writeFileSync","removeItem","buffer","flushTimer","flushInterval","setInterval","flush","push","batchSize","globalThis","process","dest","destination","close","clearInterval","url","records","fetch","headers","body","logs","unshift","handler","addHandler","type","serializer","priority","addSerializer","target","addTransport","api","badgeName","badge","badgeList","badges","clearBadges","command","cli","closeTransports","component","StyleBuilder","critical","debug","flushTransports","label","collapsed","group","groupEnd","duration","logAnimated","svgContent","logWithSVG","event","callback","off","on","once","removeSerializer","id","removeTransport","scope","bannerType","setBannerType","setGlobalPrefix","setTheme","setVerbosity","showBanner","data","columns","table","time","timeEnd","trace","middleware","use"],"mappings":"ySAuBMA,EAA6C,CAC/CC,WAAY,IACZC,IAAK,IACLC,SAAS,GAGN,MAAMC,WACDC,yBAAqCC,IACrCC,OACAC,SAAW,EACXC,UAAY,EAEpB,WAAAC,CAAYH,EAA2B,IACnCI,KAAKJ,OAAS,IAAKP,KAAmBO,EAC1C,CAEQ,WAAAK,CAAYC,GAChB,MAAO,GAAGA,EAAIC,SAASD,EAAIE,SAASF,EAAIG,YAAc,aAAaH,EAAII,aAAaJ,EAAIK,aAC5F,CAEA,GAAAC,CAAIN,GACA,IAAKF,KAAKJ,OAAOJ,QAAS,OAAO,KAEjC,MAAMiB,EAAWT,KAAKC,YAAYC,GAC5BQ,EAAQV,KAAKN,MAAMc,IAAIC,GAE7B,OAAKC,EAKDC,KAAKC,MAAQF,EAAMG,UAAYb,KAAKJ,OAAOL,KAC3CS,KAAKN,MAAMoB,OAAOL,GAClBT,KAAKF,YACE,OAGXY,EAAMK,OACNf,KAAKN,MAAMoB,OAAOL,GAClBT,KAAKN,MAAMsB,IAAIP,EAAUC,GACzBV,KAAKH,WAEEa,IAfHV,KAAKF,YACE,KAef,CAEA,GA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J,IAAID,EAAY/C,gBA/GZ,IAAIjE,IAAgBlC,YAAYiC,QAAQC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/styling/StyleCache.ts","../src/index.ts","../src/handlers/AnalyticsLogHandler.ts","../src/writers/BufferWriter.ts","../src/transports/ConsoleTransport.ts","../src/handlers/FileLogHandler.ts","../src/transports/FileTransport.ts","../src/transports/HttpTransport.ts"],"sourcesContent":["import type { LogLevel, DevToolsTheme } from '../types/core.js';\n\ninterface CacheKey {\n level: LogLevel | 'success';\n theme: DevToolsTheme;\n presetName?: string;\n hasPrefix: boolean;\n hasLocation: boolean;\n}\n\ninterface CacheEntry {\n styles: string[];\n format: string;\n createdAt: number;\n hits: number;\n}\n\nexport interface StyleCacheConfig {\n maxEntries?: number;\n ttl?: number;\n enabled?: boolean;\n}\n\nconst DEFAULT_CONFIG: Required<StyleCacheConfig> = {\n maxEntries: 100,\n ttl: 5 * 60 * 1000,\n enabled: true\n};\n\nexport class StyleCache {\n private cache: Map<string, CacheEntry> = new Map();\n private config: Required<StyleCacheConfig>;\n private hitCount = 0;\n private missCount = 0;\n\n constructor(config: StyleCacheConfig = {}) {\n this.config = { ...DEFAULT_CONFIG, ...config };\n }\n\n private generateKey(key: CacheKey): string {\n return `${key.level}:${key.theme}:${key.presetName || 'default'}:${key.hasPrefix}:${key.hasLocation}`;\n }\n\n get(key: CacheKey): CacheEntry | null {\n if (!this.config.enabled) return null;\n\n const cacheKey = this.generateKey(key);\n const entry = this.cache.get(cacheKey);\n\n if (!entry) {\n this.missCount++;\n return null;\n }\n\n if (Date.now() - entry.createdAt > this.config.ttl) {\n this.cache.delete(cacheKey);\n this.missCount++;\n return null;\n }\n\n entry.hits++;\n this.cache.delete(cacheKey);\n this.cache.set(cacheKey, entry);\n this.hitCount++;\n\n return entry;\n }\n\n set(key: CacheKey, format: string, styles: string[]): void {\n if (!this.config.enabled) return;\n\n const cacheKey = this.generateKey(key);\n\n if (this.cache.size >= this.config.maxEntries) {\n const firstKey = this.cache.keys().next().value;\n if (firstKey) {\n this.cache.delete(firstKey);\n }\n }\n\n this.cache.set(cacheKey, {\n format,\n styles: [...styles],\n createdAt: Date.now(),\n hits: 0\n });\n }\n\n clear(): void {\n this.cache.clear();\n this.hitCount = 0;\n this.missCount = 0;\n }\n\n getStats(): {\n size: number;\n maxSize: number;\n hitRate: number;\n hits: number;\n misses: number;\n } {\n const total = this.hitCount + this.missCount;\n return {\n size: this.cache.size,\n maxSize: this.config.maxEntries,\n hitRate: total > 0 ? this.hitCount / total : 0,\n hits: this.hitCount,\n misses: this.missCount\n };\n }\n\n setEnabled(enabled: boolean): void {\n this.config.enabled = enabled;\n if (!enabled) {\n this.clear();\n }\n }\n\n isEnabled(): boolean {\n return this.config.enabled;\n }\n}\n\nlet _styleCache: StyleCache | null = null;\n\nexport function getStyleCache(): StyleCache {\n if (!_styleCache) {\n _styleCache = new StyleCache();\n }\n return _styleCache;\n}\n","/**\n * @fileoverview Better Logger - Librería completa con todas las características\n * @version 0.3.0\n * @since 2024\n * \n * Punto de entrada principal que proporciona la experiencia completa de Better Logger\n * con características avanzadas incluyendo estilos CSS, soporte SVG, animaciones,\n * capacidades de exportación y logging remoto.\n * \n * @module @mks2508/better-logger\n */\n\n// Main Logger class with all features\nimport { Logger } from './Logger.js';\nimport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler\n} from './types/index.js';\n\n// Lazy singleton - se inicializa solo cuando se necesita\nlet _logger: Logger | null = null;\n\nfunction getLogger(): Logger {\n if (!_logger) {\n _logger = new Logger();\n }\n return _logger;\n}\n\n/**\n * Clase principal Logger con conjunto completo de características\n * \n * @example\n * // Importación y uso básico\n * import { Logger } from '@mks2508/better-logger';\n * \n * const logger = new Logger();\n * logger.preset('cyberpunk'); // Aplicar preset completo\n * logger.info('¡Hola mundo!');\n * \n * @example\n * // Logger con scope para componentes\n * const auth = logger.component('Auth');\n * auth.info('Usuario autenticando...');\n * auth.success('Login exitoso');\n * \n * @example\n * // Logger para APIs con badges\n * const api = logger.api('GraphQL');\n * api.badges(['v2', 'cached']).info('Query ejecutada');\n * \n * @since 0.3.0\n */\nexport { Logger };\n\n/**\n * Instancia singleton del logger lista para usar\n * @default\n * \n * @example\n * // Uso directo sin crear instancia\n * import logger from '@mks2508/better-logger';\n * \n * logger.info('Aplicación iniciada');\n * logger.success('Conexión establecida');\n * logger.warn('Memoria al 80%');\n * logger.error('Fallo en conexión');\n */\nexport default getLogger();\n\n/**\n * Métodos de logging individuales (enlazados al singleton)\n * \n * @example\n * // Importar solo los métodos necesarios\n * import { info, error, success } from '@mks2508/better-logger';\n * \n * info('Proceso iniciado');\n * success('✓ Completado exitosamente');\n * error('Error:', errorDetails);\n * \n * @since 0.3.0\n */\nexport const debug = (...args: any[]) => getLogger().debug(...args);\nexport const info = (...args: any[]) => getLogger().info(...args);\nexport const warn = (...args: any[]) => getLogger().warn(...args);\nexport const error = (...args: any[]) => getLogger().error(...args);\nexport const success = (...args: any[]) => getLogger().success(...args);\nexport const critical = (...args: any[]) => getLogger().critical(...args);\nexport const trace = (...args: any[]) => getLogger().trace(...args);\nexport const table = (data: any, columns?: string[]) => getLogger().table(data, columns);\nexport const group = (label: string, collapsed?: boolean) => getLogger().group(label, collapsed);\nexport const groupEnd = () => getLogger().groupEnd();\nexport const time = (label: string) => getLogger().time(label);\nexport const timeEnd = (label: string) => getLogger().timeEnd(label);\nexport const setGlobalPrefix = (prefix: string) => getLogger().setGlobalPrefix(prefix);\nexport const scope = (name: string) => getLogger().scope(name);\nexport const component = (name: string) => getLogger().component(name);\nexport const api = (name: string) => getLogger().api(name);\nexport const badges = (badgeList: string[]) => getLogger().badges(badgeList);\nexport const badge = (badgeName: string) => getLogger().badge(badgeName);\nexport const clearBadges = () => getLogger().clearBadges();\nexport const setVerbosity = (level: Verbosity) => getLogger().setVerbosity(level);\nexport const addHandler = (handler: ILogHandler) => getLogger().addHandler(handler);\nexport const setTheme = (theme: ThemeVariant) => getLogger().setTheme(theme);\nexport const setBannerType = (bannerType: BannerType) => getLogger().setBannerType(bannerType);\nexport const showBanner = (bannerType?: BannerType) => getLogger().showBanner(bannerType);\nexport const logWithSVG = (message: string, svgContent?: string, options?: StyleOptions) => \n getLogger().logWithSVG(message, svgContent, options);\nexport const logAnimated = (message: string, duration?: number) => \n getLogger().logAnimated(message, duration);\nexport const cli = (command: string) => getLogger().cli(command);\n\n// Type exports\nexport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler,\n LoggerConfig,\n LogMetadata,\n StackInfo,\n TimerEntry,\n TimerResult,\n OutputFormat,\n IScopedLogger,\n IAPILogger,\n IComponentLogger,\n Bindings,\n SerializerFn,\n SerializerContext,\n SerializerConfig,\n ISerializerRegistry,\n HookLogEntry,\n HookEvent,\n HookCallback,\n MiddlewareFn,\n IHookManager,\n TransportRecord,\n TransportOptions,\n TransportTarget,\n ITransport,\n StyleCacheConfig,\n BadgeStyle,\n TimestampFormat,\n ColumnAlign,\n ColumnConfig,\n LogOptions,\n} from './types/index.js';\n\n// Styling utilities\nexport { \n StyleBuilder,\n StylePresets,\n THEME_PRESETS,\n THEME_BANNERS,\n BANNER_VARIANTS\n} from './styling/index.js';\n\n// Handler exports\nexport {\n FileLogHandler,\n RemoteLogHandler,\n AnalyticsLogHandler\n} from './handlers/index.js';\n\n// Serializers\nexport { SerializerRegistry } from './serializers/index.js';\n\n// Hooks & Middleware\nexport { HookManager } from './hooks/index.js';\n\n// Transports\nexport {\n TransportManager,\n ConsoleTransport,\n FileTransport,\n HttpTransport\n} from './transports/index.js';\n\n// Style Cache\nexport { StyleCache, getStyleCache } from './styling/StyleCache.js';\n\n// Enterprise feature function exports\nimport type { SerializerFn, HookEvent, HookCallback, MiddlewareFn, TransportTarget } from './types/index.js';\nexport const addSerializer = <T>(\n type: new (...args: any[]) => T,\n serializer: SerializerFn<T>,\n priority?: number\n) => getLogger().addSerializer(type, serializer, priority);\nexport const removeSerializer = <T>(type: new (...args: any[]) => T) =>\n getLogger().removeSerializer(type);\nexport const on = (event: HookEvent, callback: HookCallback, priority?: number) =>\n getLogger().on(event, callback, priority);\nexport const once = (event: HookEvent, callback: HookCallback, priority?: number) =>\n getLogger().once(event, callback, priority);\nexport const off = (event: HookEvent, callback: HookCallback) =>\n getLogger().off(event, callback);\nexport const use = (middleware: MiddlewareFn, priority?: number) =>\n getLogger().use(middleware, priority);\nexport const addTransport = (target: TransportTarget) =>\n getLogger().addTransport(target);\nexport const removeTransport = (id: string) =>\n getLogger().removeTransport(id);\nexport const flushTransports = () =>\n getLogger().flushTransports();\nexport const closeTransports = () =>\n getLogger().closeTransports();\n\n// Scoped loggers\nexport {\n ScopedLogger,\n APILogger,\n ComponentLogger,\n ContextLogger\n} from './ScopedLogger.js';\n\n// Constants\nexport { DEFAULT_CONFIG } from './constants.js';\n\n// Utility exports\nexport {\n parseStackTrace,\n formatTimestamp,\n detectOptimalFormat,\n createOutput,\n createANSIOutput,\n createBuildOutput,\n createCIOutput\n} from './utils/index.js';\n\n// ANSI color utilities\nexport {\n ansiStyle,\n ansiColor,\n ansiBackground,\n ansiBold,\n ansiDim,\n ansiUnderline,\n formatLogLevelANSI,\n formatSuccessANSI,\n BUILD_FORMATTERS,\n sanitizeEmojis\n} from './utils/ansi-colors.js';\n\n// Environment detection and presets\nexport {\n BUILD_PRESETS,\n ENVIRONMENT_DETECTION,\n detectEnvironmentPreset,\n getOptimalConfig\n} from './constants.js';\n\n/**\n * Utilidades de estilo para crear estilos personalizados de consola\n * \n * @example\n * // Crear estilo personalizado\n * import { createStyle, stylePresets } from '@mks2508/better-logger';\n * \n * const miEstilo = createStyle()\n * .bg('linear-gradient(45deg, #ff6b6b, #feca57)')\n * .color('white')\n * .padding('10px')\n * .rounded('8px')\n * .bold()\n * .build();\n * \n * console.log('%cMensaje estilizado', miEstilo);\n * \n * @example\n * // Usar presets predefinidos\n * console.log('%cÉxito!', stylePresets.success);\n * console.log('%cError!', stylePresets.error);\n * \n * @since 0.3.0\n */\nimport { StyleBuilder, StylePresets } from './styling/index.js';\n\n/**\n * Crea una nueva instancia de StyleBuilder para estilos personalizados de consola\n * \n * @returns {StyleBuilder} Constructor de estilos encadenable\n * \n * @example\n * const estilo = createStyle()\n * .gradient('#667eea', '#764ba2')\n * .color('white')\n * .padding('8px 16px')\n * .rounded('4px')\n * .shadow('0 2px 4px rgba(0,0,0,0.2)')\n * .build();\n * \n * @since 0.3.0\n */\nexport const createStyle = () => new StyleBuilder();\n\n/**\n * Presets de estilo predefinidos para casos de uso comunes\n * \n * @constant {Object} stylePresets\n * \n * @example\n * console.log('%cOperación exitosa', stylePresets.success);\n * console.log('%cAdvertencia', stylePresets.warning);\n * console.log('%cError crítico', stylePresets.error);\n * console.log('%cInformación', stylePresets.info);\n * console.log('%cDestacado', stylePresets.accent);\n * \n * @since 0.3.0\n */\nexport const stylePresets = {\n success: StylePresets.success().build(),\n error: StylePresets.error().build(),\n warning: StylePresets.warning().build(),\n info: StylePresets.info().build(),\n accent: StylePresets.accent().build(),\n};\n\n// Terminal formatting utilities\nexport {\n formatWithRightAlign,\n formatColumns,\n formatKeyValue,\n formatBadge,\n formatTimestamp as formatTimestampExt,\n formatRelativeTime,\n formatElapsedTime,\n resetStartTime,\n isKeyValueObject,\n stripAnsi,\n getVisibleLength,\n padToWidth,\n applyLogOptions,\n} from './terminal/formatter.js';\n\n// Color converter utilities\nexport {\n hexToRgb,\n rgbToHex,\n hexTo256,\n colorToHex,\n getANSIForeground,\n getANSIBackground,\n getANSI256Foreground,\n getANSI256Background,\n cssColorToANSI,\n ANSI,\n} from './terminal/color-converter.js';\n\nexport type { RGB, ColorCapability } from './terminal/color-converter.js';\n\n// Terminal renderer\nexport { TerminalRenderer } from './terminal/terminal-renderer.js';\nexport type { ANSIStyle, ChalkLikeInterface } from './terminal/terminal-renderer.js';\n\n// Environment detection\nexport {\n getEnvironment,\n isRunningInTerminal,\n supportsANSI,\n getColorCapability,\n getTerminalWidth,\n getTerminalHeight,\n getEnvironmentInfo,\n} from './utils/environment-detector.js';\n\nexport type { Environment } from './utils/environment-detector.js';\n\n// Output writers for custom log destinations\nexport { BufferWriter, type BufferEntry } from './writers/index.js';\nexport type { OutputWriter, OutputMode } from './types/core.js';","/**\n * @fileoverview Analytics log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\n\n/**\n * Example custom handler for analytics demonstration\n */\nexport class AnalyticsLogHandler implements ILogHandler {\n handle(level: LogLevel, message: string, _args: any[], metadata: LogMetadata): void {\n // In a real implementation, this could send analytics data\n if (level === 'error' || level === 'critical') {\n // Track errors for analytics\n console.debug('Analytics: Error tracked', { \n level, \n message, \n timestamp: metadata.timestamp \n });\n }\n }\n}","/**\n * @fileoverview BufferWriter - Collects log output in memory for later use\n * @version 4.0.0\n */\n\nimport type { LogLevel, OutputWriter } from '../types/core.js';\n\n/**\n * Entry in the log buffer\n */\nexport interface BufferEntry {\n message: string;\n level: LogLevel;\n styles: string[];\n timestamp: number;\n}\n\n/**\n * BufferWriter collects log messages in memory instead of outputting to console.\n * Useful for:\n * - CLI operations with spinners (buffer logs during spinner, show after)\n * - Testing (capture logs for assertions)\n * - Batch processing (collect logs, process together)\n *\n * @implements {OutputWriter}\n * @since 4.0.0\n *\n * @example\n * import logger, { BufferWriter } from '@mks2508/better-logger';\n *\n * const buffer = new BufferWriter();\n * logger.updateConfig({\n * outputMode: 'custom',\n * outputWriter: buffer\n * });\n *\n * // Logs go to buffer, not console\n * spinner.start('Loading...');\n * logger.info('Connecting...');\n * logger.info('Processing...');\n * spinner.stop();\n *\n * // Show buffered logs\n * logger.updateConfig({ outputMode: 'console' });\n * buffer.flush(); // Outputs all buffered logs to console\n */\nexport class BufferWriter implements OutputWriter {\n private buffer: BufferEntry[] = [];\n private maxSize: number;\n\n /**\n * Creates a new BufferWriter\n * @param maxSize - Maximum number of entries to buffer (default: 1000)\n */\n constructor(maxSize: number = 1000) {\n this.maxSize = maxSize;\n }\n\n /**\n * Writes a log entry to the buffer\n * @param message - Formatted log message\n * @param level - Log level\n * @param styles - CSS styles (for browser console)\n */\n write(message: string, level: LogLevel, styles: string[]): void {\n if (this.buffer.length >= this.maxSize) {\n this.buffer.shift(); // Remove oldest entry\n }\n\n this.buffer.push({\n message,\n level,\n styles,\n timestamp: Date.now()\n });\n }\n\n /**\n * Returns all buffered entries\n * @returns Copy of the buffer array\n */\n getBuffer(): BufferEntry[] {\n return [...this.buffer];\n }\n\n /**\n * Returns buffered entries filtered by log level\n * @param levels - Log levels to include\n * @returns Filtered buffer entries\n */\n getByLevel(...levels: LogLevel[]): BufferEntry[] {\n return this.buffer.filter(entry => levels.includes(entry.level));\n }\n\n /**\n * Returns the number of buffered entries\n */\n get size(): number {\n return this.buffer.length;\n }\n\n /**\n * Checks if buffer is empty\n */\n get isEmpty(): boolean {\n return this.buffer.length === 0;\n }\n\n /**\n * Clears all buffered entries\n */\n clear(): void {\n this.buffer = [];\n }\n\n /**\n * Outputs all buffered entries to console and clears the buffer\n */\n flush(): void {\n this.buffer.forEach(entry => {\n if (entry.styles.length > 0) {\n console.log(entry.message, ...entry.styles);\n } else {\n console.log(entry.message);\n }\n });\n this.clear();\n }\n\n /**\n * Outputs buffered entries to console without clearing\n */\n replay(): void {\n this.buffer.forEach(entry => {\n if (entry.styles.length > 0) {\n console.log(entry.message, ...entry.styles);\n } else {\n console.log(entry.message);\n }\n });\n }\n\n /**\n * Returns all messages as an array of strings\n */\n toArray(): string[] {\n return this.buffer.map(entry => entry.message);\n }\n\n /**\n * Returns all messages joined as a single string\n * @param separator - String to join messages with (default: newline)\n */\n toString(separator: string = '\\n'): string {\n return this.toArray().join(separator);\n }\n}\n","import type { TransportRecord, TransportOptions, ITransport, LogLevel } from '../types/index.js';\n\nexport class ConsoleTransport implements ITransport {\n readonly name = 'console';\n\n constructor(private options?: TransportOptions) {}\n\n write(record: TransportRecord): void {\n const method = this.getConsoleMethod(record.level);\n const prefix = record.prefix ? `[${record.prefix}] ` : '';\n const location = record.location\n ? ` (${record.location.file}:${record.location.line})`\n : '';\n\n console[method](`[${record.level.toUpperCase()}]${prefix} ${record.msg}${location}`);\n }\n\n private getConsoleMethod(level: LogLevel): 'log' | 'info' | 'warn' | 'error' {\n switch (level) {\n case 'debug': return 'log';\n case 'info': return 'info';\n case 'warn': return 'warn';\n case 'error':\n case 'critical': return 'error';\n default: return 'log';\n }\n }\n}\n","/**\n * @fileoverview File-based log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\nimport { isNode, isBrowser } from '../utils/environment.js';\nimport { safeSerialize } from '../utils/formatting.js';\n\n/**\n * Universal file-based log handler for persistent logging\n * Works in both Node.js (real files) and browser (localStorage)\n */\nexport class FileLogHandler implements ILogHandler {\n private filename: string;\n private maxSize?: number;\n private fs?: any; // Node.js fs module\n\n constructor(filename: string = 'app.log', maxSize?: number) {\n this.filename = filename;\n this.maxSize = maxSize;\n \n // Load Node.js fs module if in Node environment\n if (isNode) {\n try {\n this.fs = require('fs');\n } catch (error) {\n console.warn('FileLogHandler: Unable to load fs module:', error);\n }\n }\n }\n\n handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): void {\n const logEntry = {\n timestamp: metadata.timestamp,\n level: level.toUpperCase(),\n prefix: metadata.prefix,\n message,\n args: args.slice(1).map(arg => safeSerialize(arg)),\n location: metadata.stackInfo,\n };\n\n const logLine = this.formatLogLine(logEntry);\n\n if (isNode && this.fs) {\n this.writeToFileNode(logLine);\n } else if (isBrowser) {\n this.writeToFileLocal(logLine);\n } else {\n // Fallback - just console output\n console.log(`[FILE-LOG] ${logLine}`);\n }\n }\n\n /**\n * Format log entry as a single line for file storage\n */\n private formatLogLine(entry: any): string {\n const parts = [\n entry.timestamp,\n `[${entry.level}]`,\n entry.prefix ? `[${entry.prefix}]` : '',\n entry.message\n ].filter(Boolean);\n\n let line = parts.join(' ');\n \n if (entry.args && entry.args.length > 0) {\n line += ' ' + entry.args.map((arg: any) => \n typeof arg === 'object' ? JSON.stringify(arg) : String(arg)\n ).join(' ');\n }\n \n if (entry.location) {\n line += ` (${entry.location.file}:${entry.location.line}:${entry.location.column})`;\n }\n \n return line;\n }\n\n /**\n * Write to actual file in Node.js environment\n */\n private writeToFileNode(logLine: string): void {\n if (!this.fs) return;\n\n try {\n // Check file size if maxSize is set\n if (this.maxSize) {\n try {\n const stats = this.fs.statSync(this.filename);\n if (stats.size > this.maxSize) {\n // Simple rotation: backup current file and start fresh\n const backupName = `${this.filename}.bak`;\n this.fs.renameSync(this.filename, backupName);\n }\n } catch (error) {\n // File doesn't exist yet, that's fine\n }\n }\n\n // Append to file\n this.fs.appendFileSync(this.filename, logLine + '\\n', 'utf8');\n } catch (error) {\n console.error('FileLogHandler: Failed to write to file:', error);\n }\n }\n\n /**\n * Write to localStorage in browser environment\n */\n private writeToFileLocal(logLine: string): void {\n try {\n const storageKey = `logger_${this.filename}`;\n const existingLogs = localStorage.getItem(storageKey) || '';\n \n let newLogs = existingLogs;\n if (existingLogs.length > 0) {\n newLogs += '\\n';\n }\n newLogs += logLine;\n \n // Simple size management - keep last 1000 lines max\n if (this.maxSize || newLogs.split('\\n').length > 1000) {\n const lines = newLogs.split('\\n');\n const maxLines = this.maxSize ? Math.floor(this.maxSize / 100) : 1000;\n if (lines.length > maxLines) {\n newLogs = lines.slice(-maxLines).join('\\n');\n }\n }\n \n localStorage.setItem(storageKey, newLogs);\n } catch (error) {\n console.error('FileLogHandler: Failed to write to localStorage:', error);\n }\n }\n\n /**\n * Get stored logs (useful for debugging)\n */\n getLogs(): string | null {\n if (isNode && this.fs) {\n try {\n return this.fs.readFileSync(this.filename, 'utf8');\n } catch (error) {\n return null;\n }\n } else if (isBrowser) {\n const storageKey = `logger_${this.filename}`;\n return localStorage.getItem(storageKey);\n }\n return null;\n }\n\n /**\n * Clear stored logs\n */\n clearLogs(): void {\n if (isNode && this.fs) {\n try {\n this.fs.writeFileSync(this.filename, '', 'utf8');\n } catch (error) {\n console.error('FileLogHandler: Failed to clear file:', error);\n }\n } else if (isBrowser) {\n const storageKey = `logger_${this.filename}`;\n localStorage.removeItem(storageKey);\n }\n }\n}","import type { TransportRecord, TransportOptions, ITransport } from '../types/index.js';\n\nexport interface FileTransportOptions extends TransportOptions {\n destination?: string;\n}\n\nexport class FileTransport implements ITransport {\n readonly name = 'file';\n private buffer: string[] = [];\n private flushTimer?: ReturnType<typeof setInterval>;\n private options: FileTransportOptions;\n\n constructor(options?: FileTransportOptions) {\n this.options = options || {};\n\n if (this.options.flushInterval) {\n this.flushTimer = setInterval(() => this.flush(), this.options.flushInterval);\n }\n }\n\n write(record: TransportRecord): void {\n const line = JSON.stringify(record) + '\\n';\n this.buffer.push(line);\n\n if (this.buffer.length >= (this.options.batchSize || 100)) {\n this.flush();\n }\n }\n\n async flush(): Promise<void> {\n if (this.buffer.length === 0) return;\n\n const lines = this.buffer.join('');\n this.buffer = [];\n\n if (typeof globalThis.process !== 'undefined' && typeof require === 'function') {\n try {\n const fs = require('fs');\n const dest = this.options.destination || 'app.log';\n fs.appendFileSync(dest, lines);\n } catch {\n // Silent fail in browser or if fs not available\n }\n }\n }\n\n close(): void {\n if (this.flushTimer) {\n clearInterval(this.flushTimer);\n }\n this.flush();\n }\n}\n","import type { TransportRecord, TransportOptions, ITransport } from '../types/index.js';\n\nexport interface HttpTransportOptions extends TransportOptions {\n url?: string;\n headers?: Record<string, string>;\n}\n\nexport class HttpTransport implements ITransport {\n readonly name = 'http';\n private buffer: TransportRecord[] = [];\n private flushTimer?: ReturnType<typeof setInterval>;\n private options: HttpTransportOptions;\n\n constructor(options?: HttpTransportOptions) {\n this.options = options || {};\n\n if (this.options.flushInterval) {\n this.flushTimer = setInterval(() => this.flush(), this.options.flushInterval);\n }\n }\n\n write(record: TransportRecord): void {\n this.buffer.push(record);\n\n if (this.buffer.length >= (this.options.batchSize || 50)) {\n this.flush();\n }\n }\n\n async flush(): Promise<void> {\n if (this.buffer.length === 0 || !this.options.url) return;\n\n const records = [...this.buffer];\n this.buffer = [];\n\n try {\n await fetch(this.options.url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...this.options.headers\n },\n body: JSON.stringify({ logs: records })\n });\n } catch {\n this.buffer.unshift(...records);\n }\n }\n\n close(): void {\n if (this.flushTimer) {\n clearInterval(this.flushTimer);\n }\n this.flush();\n }\n}\n"],"names":["DEFAULT_CONFIG","maxEntries","ttl","enabled","StyleCache","cache","Map","config","hitCount","missCount","constructor","this","generateKey","key","level","theme","presetName","hasPrefix","hasLocation","get","cacheKey","entry","Date","now","createdAt","delete","hits","set","format","styles","size","firstKey","keys","next","value","clear","getStats","total","maxSize","hitRate","misses","setEnabled","isEnabled","_styleCache","_logger","getLogger","Logger","index","stylePresets","success","StylePresets","build","error","warning","info","accent","handle","message","_args","metadata","timestamp","buffer","write","length","shift","push","getBuffer","getByLevel","levels","filter","includes","isEmpty","flush","forEach","console","log","replay","toArray","map","toString","separator","join","options","name","record","method","getConsoleMethod","prefix","location","file","line","toUpperCase","msg","filename","fs","isNode","require","warn","args","logEntry","slice","arg","safeSerialize","stackInfo","logLine","formatLogLine","writeToFileNode","isBrowser","writeToFileLocal","Boolean","JSON","stringify","String","column","statSync","backupName","renameSync","appendFileSync","storageKey","existingLogs","localStorage","getItem","newLogs","split","lines","maxLines","Math","floor","setItem","getLogs","readFileSync","clearLogs","writeFileSync","removeItem","flushTimer","flushInterval","setInterval","batchSize","globalThis","process","dest","destination","close","clearInterval","url","records","fetch","headers","body","logs","unshift","handler","addHandler","type","serializer","priority","addSerializer","target","addTransport","api","badgeName","badge","badgeList","badges","clearBadges","command","cli","closeTransports","component","StyleBuilder","critical","debug","flushTransports","label","collapsed","group","groupEnd","duration","logAnimated","svgContent","logWithSVG","event","callback","off","on","once","removeSerializer","id","removeTransport","scope","bannerType","setBannerType","setGlobalPrefix","setTheme","setVerbosity","showBanner","data","columns","table","time","timeEnd","trace","middleware","use"],"mappings":"ySAuBMA,EAA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YAAY6I,iBAAiBjC,2BAWDkC,GAC5B9I,YAAY+I,gBAAgBD,iBA7GVxG,GAAiBtC,YAAYgJ,MAAM1G,yBAS3B2G,GAA2BjJ,YAAYkJ,cAAcD,2BAVnDvG,GAAmB1C,YAAYmJ,gBAAgBzG,oBAStDxE,GAAwB8B,YAAYoJ,SAASlL,wBAFzCD,GAAqB+B,YAAYqJ,aAAapL,sBAIhDgL,GAA4BjJ,YAAYsJ,WAAWL,0CAnBvD,IAAI5F,IAAgBrD,YAAYI,WAAWiD,iBAG7C,CAACkG,EAAWC,IAAuBxJ,YAAYyJ,MAAMF,EAAMC,gBAG3DxB,GAAkBhI,YAAY0J,KAAK1B,mBAChCA,GAAkBhI,YAAY2J,QAAQ3B,iBALzC,IAAI3E,IAAgBrD,YAAY4J,SAASvG,eA+G3C,CAACwG,EAA0B/C,IAC1C9G,YAAY8J,IAAID,EAAY/C,gBApHZ,IAAIzD,IAAgBrD,YAAYoD,QAAQC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export declare const showBanner: (bannerType?: BannerType) => void;
|
|
|
81
81
|
export declare const logWithSVG: (message: string, svgContent?: string, options?: StyleOptions) => void;
|
|
82
82
|
export declare const logAnimated: (message: string, duration?: number) => void;
|
|
83
83
|
export declare const cli: (command: string) => Promise<void>;
|
|
84
|
-
export type { LogLevel, Verbosity, ThemeVariant, BannerType, StyleOptions, ILogHandler, LoggerConfig, LogMetadata, StackInfo, TimerEntry, TimerResult, OutputFormat, IScopedLogger, IAPILogger, IComponentLogger, Bindings, SerializerFn, SerializerContext, SerializerConfig, ISerializerRegistry, HookLogEntry, HookEvent, HookCallback, MiddlewareFn, IHookManager, TransportRecord, TransportOptions, TransportTarget, ITransport, StyleCacheConfig } from './types/index.js';
|
|
84
|
+
export type { LogLevel, Verbosity, ThemeVariant, BannerType, StyleOptions, ILogHandler, LoggerConfig, LogMetadata, StackInfo, TimerEntry, TimerResult, OutputFormat, IScopedLogger, IAPILogger, IComponentLogger, Bindings, SerializerFn, SerializerContext, SerializerConfig, ISerializerRegistry, HookLogEntry, HookEvent, HookCallback, MiddlewareFn, IHookManager, TransportRecord, TransportOptions, TransportTarget, ITransport, StyleCacheConfig, BadgeStyle, TimestampFormat, ColumnAlign, ColumnConfig, LogOptions, } from './types/index.js';
|
|
85
85
|
export { StyleBuilder, StylePresets, THEME_PRESETS, THEME_BANNERS, BANNER_VARIANTS } from './styling/index.js';
|
|
86
86
|
export { FileLogHandler, RemoteLogHandler, AnalyticsLogHandler } from './handlers/index.js';
|
|
87
87
|
export { SerializerRegistry } from './serializers/index.js';
|
|
@@ -141,4 +141,13 @@ export declare const stylePresets: {
|
|
|
141
141
|
info: string;
|
|
142
142
|
accent: string;
|
|
143
143
|
};
|
|
144
|
+
export { formatWithRightAlign, formatColumns, formatKeyValue, formatBadge, formatTimestamp as formatTimestampExt, formatRelativeTime, formatElapsedTime, resetStartTime, isKeyValueObject, stripAnsi, getVisibleLength, padToWidth, applyLogOptions, } from './terminal/formatter.js';
|
|
145
|
+
export { hexToRgb, rgbToHex, hexTo256, colorToHex, getANSIForeground, getANSIBackground, getANSI256Foreground, getANSI256Background, cssColorToANSI, ANSI, } from './terminal/color-converter.js';
|
|
146
|
+
export type { RGB, ColorCapability } from './terminal/color-converter.js';
|
|
147
|
+
export { TerminalRenderer } from './terminal/terminal-renderer.js';
|
|
148
|
+
export type { ANSIStyle, ChalkLikeInterface } from './terminal/terminal-renderer.js';
|
|
149
|
+
export { getEnvironment, isRunningInTerminal, supportsANSI, getColorCapability, getTerminalWidth, getTerminalHeight, getEnvironmentInfo, } from './utils/environment-detector.js';
|
|
150
|
+
export type { Environment } from './utils/environment-detector.js';
|
|
151
|
+
export { BufferWriter, type BufferEntry } from './writers/index.js';
|
|
152
|
+
export type { OutputWriter, OutputMode } from './types/core.js';
|
|
144
153
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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Ae,EAAE,MAAM,+BAA+B,CAAC;AAG1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGrF,OAAO,EACH,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { L as Logger } from "./chunks/Logger-
|
|
2
|
-
import { A, B, C, d, H, c, S, a, T, b } from "./chunks/Logger-
|
|
3
|
-
import { i as isNode, a as isBrowser, S as StylePresets, b as StyleBuilder } from "./chunks/environment-
|
|
4
|
-
import { B as B2, D, E, d as d2, f, g, p } from "./chunks/environment-
|
|
5
|
-
import { s as safeSerialize } from "./chunks/formatting-
|
|
6
|
-
import { B as B3, h, i, g as
|
|
1
|
+
import { L as Logger } from "./chunks/Logger-D-gmmgR2.js";
|
|
2
|
+
import { A, B, C, d, H, c, S, a, T, b, n, h, e, k, g, j, i, f, m, l, p, r, s } from "./chunks/Logger-D-gmmgR2.js";
|
|
3
|
+
import { i as isNode, a as isBrowser, S as StylePresets, b as StyleBuilder } from "./chunks/environment-COWvu6Wz.js";
|
|
4
|
+
import { A as A2, B as B2, D, E, T as T2, e as e2, n as n2, d as d2, f as f2, m as m2, l as l2, k as k2, j as j2, t, o, w, g as g2, v, u, c as c2, h as h2, q, p as p2, r as r2, s as s2 } from "./chunks/environment-COWvu6Wz.js";
|
|
5
|
+
import { s as safeSerialize } from "./chunks/formatting-CYjT9yhO.js";
|
|
6
|
+
import { B as B3, h as h3, i as i2, g as g3, j as j3, f as f3, k as k3, a as a2, b as b2, e as e3, c as c3, d as d3, l as l3, m as m3, n as n3 } from "./chunks/formatting-CYjT9yhO.js";
|
|
7
7
|
import { R } from "./chunks/RemoteLogHandler-CjWpWZGl.js";
|
|
8
8
|
class ConsoleTransport {
|
|
9
9
|
constructor(options) {
|
|
@@ -337,6 +337,105 @@ function getStyleCache() {
|
|
|
337
337
|
}
|
|
338
338
|
return _styleCache;
|
|
339
339
|
}
|
|
340
|
+
class BufferWriter {
|
|
341
|
+
buffer = [];
|
|
342
|
+
maxSize;
|
|
343
|
+
/**
|
|
344
|
+
* Creates a new BufferWriter
|
|
345
|
+
* @param maxSize - Maximum number of entries to buffer (default: 1000)
|
|
346
|
+
*/
|
|
347
|
+
constructor(maxSize = 1e3) {
|
|
348
|
+
this.maxSize = maxSize;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Writes a log entry to the buffer
|
|
352
|
+
* @param message - Formatted log message
|
|
353
|
+
* @param level - Log level
|
|
354
|
+
* @param styles - CSS styles (for browser console)
|
|
355
|
+
*/
|
|
356
|
+
write(message, level, styles) {
|
|
357
|
+
if (this.buffer.length >= this.maxSize) {
|
|
358
|
+
this.buffer.shift();
|
|
359
|
+
}
|
|
360
|
+
this.buffer.push({
|
|
361
|
+
message,
|
|
362
|
+
level,
|
|
363
|
+
styles,
|
|
364
|
+
timestamp: Date.now()
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Returns all buffered entries
|
|
369
|
+
* @returns Copy of the buffer array
|
|
370
|
+
*/
|
|
371
|
+
getBuffer() {
|
|
372
|
+
return [...this.buffer];
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Returns buffered entries filtered by log level
|
|
376
|
+
* @param levels - Log levels to include
|
|
377
|
+
* @returns Filtered buffer entries
|
|
378
|
+
*/
|
|
379
|
+
getByLevel(...levels) {
|
|
380
|
+
return this.buffer.filter((entry) => levels.includes(entry.level));
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Returns the number of buffered entries
|
|
384
|
+
*/
|
|
385
|
+
get size() {
|
|
386
|
+
return this.buffer.length;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Checks if buffer is empty
|
|
390
|
+
*/
|
|
391
|
+
get isEmpty() {
|
|
392
|
+
return this.buffer.length === 0;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Clears all buffered entries
|
|
396
|
+
*/
|
|
397
|
+
clear() {
|
|
398
|
+
this.buffer = [];
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Outputs all buffered entries to console and clears the buffer
|
|
402
|
+
*/
|
|
403
|
+
flush() {
|
|
404
|
+
this.buffer.forEach((entry) => {
|
|
405
|
+
if (entry.styles.length > 0) {
|
|
406
|
+
console.log(entry.message, ...entry.styles);
|
|
407
|
+
} else {
|
|
408
|
+
console.log(entry.message);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
this.clear();
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Outputs buffered entries to console without clearing
|
|
415
|
+
*/
|
|
416
|
+
replay() {
|
|
417
|
+
this.buffer.forEach((entry) => {
|
|
418
|
+
if (entry.styles.length > 0) {
|
|
419
|
+
console.log(entry.message, ...entry.styles);
|
|
420
|
+
} else {
|
|
421
|
+
console.log(entry.message);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Returns all messages as an array of strings
|
|
427
|
+
*/
|
|
428
|
+
toArray() {
|
|
429
|
+
return this.buffer.map((entry) => entry.message);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Returns all messages joined as a single string
|
|
433
|
+
* @param separator - String to join messages with (default: newline)
|
|
434
|
+
*/
|
|
435
|
+
toString(separator = "\n") {
|
|
436
|
+
return this.toArray().join(separator);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
340
439
|
let _logger = null;
|
|
341
440
|
function getLogger() {
|
|
342
441
|
if (!_logger) {
|
|
@@ -391,11 +490,13 @@ const stylePresets = {
|
|
|
391
490
|
accent: StylePresets.accent().build()
|
|
392
491
|
};
|
|
393
492
|
export {
|
|
493
|
+
A2 as ANSI,
|
|
394
494
|
A as APILogger,
|
|
395
495
|
AnalyticsLogHandler,
|
|
396
496
|
B as BANNER_VARIANTS,
|
|
397
497
|
B3 as BUILD_FORMATTERS,
|
|
398
498
|
B2 as BUILD_PRESETS,
|
|
499
|
+
BufferWriter,
|
|
399
500
|
C as ComponentLogger,
|
|
400
501
|
ConsoleTransport,
|
|
401
502
|
d as ContextLogger,
|
|
@@ -414,60 +515,90 @@ export {
|
|
|
414
515
|
StylePresets,
|
|
415
516
|
a as THEME_BANNERS,
|
|
416
517
|
T as THEME_PRESETS,
|
|
518
|
+
T2 as TerminalRenderer,
|
|
417
519
|
b as TransportManager,
|
|
418
520
|
addHandler,
|
|
419
521
|
addSerializer,
|
|
420
522
|
addTransport,
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
523
|
+
h3 as ansiBackground,
|
|
524
|
+
i2 as ansiBold,
|
|
525
|
+
g3 as ansiColor,
|
|
526
|
+
j3 as ansiDim,
|
|
527
|
+
f3 as ansiStyle,
|
|
528
|
+
k3 as ansiUnderline,
|
|
427
529
|
api,
|
|
530
|
+
n as applyLogOptions,
|
|
428
531
|
badge,
|
|
429
532
|
badges,
|
|
430
533
|
clearBadges,
|
|
431
534
|
cli,
|
|
432
535
|
closeTransports,
|
|
536
|
+
e2 as colorToHex,
|
|
433
537
|
component,
|
|
434
538
|
a2 as createANSIOutput,
|
|
435
539
|
b2 as createBuildOutput,
|
|
436
|
-
|
|
437
|
-
|
|
540
|
+
e3 as createCIOutput,
|
|
541
|
+
c3 as createOutput,
|
|
438
542
|
createStyle,
|
|
439
543
|
critical,
|
|
544
|
+
n2 as cssColorToANSI,
|
|
440
545
|
debug,
|
|
441
546
|
index as default,
|
|
442
547
|
d2 as detectEnvironmentPreset,
|
|
443
548
|
d3 as detectOptimalFormat,
|
|
444
549
|
error,
|
|
445
550
|
flushTransports,
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
g as
|
|
551
|
+
h as formatBadge,
|
|
552
|
+
e as formatColumns,
|
|
553
|
+
k as formatElapsedTime,
|
|
554
|
+
g as formatKeyValue,
|
|
555
|
+
l3 as formatLogLevelANSI,
|
|
556
|
+
j as formatRelativeTime,
|
|
557
|
+
m3 as formatSuccessANSI,
|
|
558
|
+
f2 as formatTimestamp,
|
|
559
|
+
i as formatTimestampExt,
|
|
560
|
+
f as formatWithRightAlign,
|
|
561
|
+
m2 as getANSI256Background,
|
|
562
|
+
l2 as getANSI256Foreground,
|
|
563
|
+
k2 as getANSIBackground,
|
|
564
|
+
j2 as getANSIForeground,
|
|
565
|
+
t as getColorCapability,
|
|
566
|
+
o as getEnvironment,
|
|
567
|
+
w as getEnvironmentInfo,
|
|
568
|
+
g2 as getOptimalConfig,
|
|
450
569
|
getStyleCache,
|
|
570
|
+
v as getTerminalHeight,
|
|
571
|
+
u as getTerminalWidth,
|
|
572
|
+
m as getVisibleLength,
|
|
451
573
|
group,
|
|
452
574
|
groupEnd,
|
|
575
|
+
c2 as hexTo256,
|
|
576
|
+
h2 as hexToRgb,
|
|
453
577
|
info,
|
|
578
|
+
l as isKeyValueObject,
|
|
579
|
+
q as isRunningInTerminal,
|
|
454
580
|
logAnimated,
|
|
455
581
|
logWithSVG,
|
|
456
582
|
off,
|
|
457
583
|
on,
|
|
458
584
|
once,
|
|
459
|
-
p as
|
|
585
|
+
p as padToWidth,
|
|
586
|
+
p2 as parseStackTrace,
|
|
460
587
|
removeSerializer,
|
|
461
588
|
removeTransport,
|
|
462
|
-
|
|
589
|
+
r as resetStartTime,
|
|
590
|
+
r2 as rgbToHex,
|
|
591
|
+
n3 as sanitizeEmojis,
|
|
463
592
|
scope,
|
|
464
593
|
setBannerType,
|
|
465
594
|
setGlobalPrefix,
|
|
466
595
|
setTheme,
|
|
467
596
|
setVerbosity,
|
|
468
597
|
showBanner,
|
|
598
|
+
s as stripAnsi,
|
|
469
599
|
stylePresets,
|
|
470
600
|
success,
|
|
601
|
+
s2 as supportsANSI,
|
|
471
602
|
table,
|
|
472
603
|
time,
|
|
473
604
|
timeEnd,
|