@ncoderz/log-m8 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/log-m8.global.js +1 -1
- package/dist/browser/log-m8.global.js.map +1 -1
- package/dist/index.cjs +50 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -3
- package/dist/index.d.ts +32 -3
- package/dist/index.js +49 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -239,7 +239,7 @@ interface Log {
|
|
|
239
239
|
*
|
|
240
240
|
* @param level - New logging level name (e.g., 'info', 'debug', 'off')
|
|
241
241
|
*/
|
|
242
|
-
setLevel(level: LogLevelType): void;
|
|
242
|
+
setLevel(level: string | LogLevelType): void;
|
|
243
243
|
/**
|
|
244
244
|
* Replaces the logger's contextual data.
|
|
245
245
|
*
|
|
@@ -484,6 +484,11 @@ interface PluginFactory<C extends PluginConfig = PluginConfig, P extends Plugin
|
|
|
484
484
|
create(config: C): P;
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
+
/**
|
|
488
|
+
* LogM8 - Central logging manager for TypeScript/JavaScript
|
|
489
|
+
*
|
|
490
|
+
*/
|
|
491
|
+
|
|
487
492
|
/**
|
|
488
493
|
* Central logging manager providing hierarchical loggers and configurable output.
|
|
489
494
|
*
|
|
@@ -614,7 +619,7 @@ declare class LogM8$1 {
|
|
|
614
619
|
* @param level - New logging level name (e.g., 'info', 'debug', 'off')
|
|
615
620
|
* @param logger - Optional logger name to set level for a specific logger
|
|
616
621
|
*/
|
|
617
|
-
setLevel(level: LogLevelType, logger?: string): void;
|
|
622
|
+
setLevel(level: string | LogLevelType, logger?: string): void;
|
|
618
623
|
/**
|
|
619
624
|
* Enables an appender to resume processing log events.
|
|
620
625
|
*
|
|
@@ -1275,6 +1280,30 @@ declare class LogM8Utils {
|
|
|
1275
1280
|
static parseRegexFromString(regex: string, extraFlags?: string[]): RegExp | undefined;
|
|
1276
1281
|
}
|
|
1277
1282
|
|
|
1283
|
+
declare class NullLogger implements Log {
|
|
1284
|
+
fatal(_message: string, ..._args: unknown[]): void;
|
|
1285
|
+
error(_message: string, ..._args: unknown[]): void;
|
|
1286
|
+
warn(_message: string, ..._args: unknown[]): void;
|
|
1287
|
+
info(_message: string, ..._args: unknown[]): void;
|
|
1288
|
+
debug(_message: string, ..._args: unknown[]): void;
|
|
1289
|
+
track(_message: string, ..._args: unknown[]): void;
|
|
1290
|
+
trace(_message: string, ..._args: unknown[]): void;
|
|
1291
|
+
readonly isFatal = false;
|
|
1292
|
+
readonly isError = false;
|
|
1293
|
+
readonly isWarn = false;
|
|
1294
|
+
readonly isInfo = false;
|
|
1295
|
+
readonly isDebug = false;
|
|
1296
|
+
readonly isTrack = false;
|
|
1297
|
+
readonly isTrace = false;
|
|
1298
|
+
readonly isEnabled = false;
|
|
1299
|
+
readonly name = "nullLogger";
|
|
1300
|
+
readonly level = "off";
|
|
1301
|
+
readonly context: LogContext;
|
|
1302
|
+
setLevel(_level: LogLevelType): void;
|
|
1303
|
+
setContext(context: LogContext): void;
|
|
1304
|
+
getLogger(_name: string): Log;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1278
1307
|
/**
|
|
1279
1308
|
* Default singleton instance of the LogM8 logging manager.
|
|
1280
1309
|
*
|
|
@@ -1295,4 +1324,4 @@ declare class LogM8Utils {
|
|
|
1295
1324
|
*/
|
|
1296
1325
|
declare const LogM8: LogM8$1;
|
|
1297
1326
|
|
|
1298
|
-
export { type Appender, type AppenderConfig, type ConsoleAppenderConfig, type DefaultFormatterConfig, type FileAppenderConfig, type Filter, type FilterConfig, type Formatter, type FormatterConfig, type Log, type LogContext, LogLevel, type LogLevelType, LogM8, LogM8Utils, type LoggingConfig, type MatchFilterConfig, type Plugin, type PluginConfig, type PluginFactory, PluginKind, type PluginKindType };
|
|
1327
|
+
export { type Appender, type AppenderConfig, type ConsoleAppenderConfig, type DefaultFormatterConfig, type FileAppenderConfig, type Filter, type FilterConfig, type Formatter, type FormatterConfig, type Log, type LogContext, LogLevel, type LogLevelType, LogM8, LogM8Utils, type LoggingConfig, type MatchFilterConfig, NullLogger, type Plugin, type PluginConfig, type PluginFactory, PluginKind, type PluginKindType };
|
package/dist/index.js
CHANGED
|
@@ -1126,12 +1126,11 @@ var LogM8 = class {
|
|
|
1126
1126
|
init(config) {
|
|
1127
1127
|
config = Object.assign({}, config);
|
|
1128
1128
|
this._reset();
|
|
1129
|
-
|
|
1130
|
-
this._globalLogLevel = this._logLevelSet.has(levelStr) ? levelStr : LogLevel.info;
|
|
1129
|
+
this.setLevel(config.level ?? LogLevel.info);
|
|
1131
1130
|
for (const [name, l] of Object.entries(config.loggers ?? {})) {
|
|
1132
|
-
const
|
|
1131
|
+
const levelStr = (l ?? "").trim().toLowerCase();
|
|
1133
1132
|
const logger = this.getLogger(name);
|
|
1134
|
-
const level = this._logLevelSet.has(
|
|
1133
|
+
const level = this._logLevelSet.has(levelStr) ? levelStr : this._globalLogLevel;
|
|
1135
1134
|
logger.setLevel(level);
|
|
1136
1135
|
}
|
|
1137
1136
|
const appenderConfigs = config.appenders ?? DEFAULT_APPENDERS;
|
|
@@ -1263,10 +1262,11 @@ var LogM8 = class {
|
|
|
1263
1262
|
* @param logger - Optional logger name to set level for a specific logger
|
|
1264
1263
|
*/
|
|
1265
1264
|
setLevel(level, logger) {
|
|
1265
|
+
const levelStr = (level ?? "").trim().toLowerCase();
|
|
1266
1266
|
if (logger) {
|
|
1267
|
-
this.getLogger(logger).setLevel(
|
|
1267
|
+
this.getLogger(logger).setLevel(levelStr);
|
|
1268
1268
|
} else {
|
|
1269
|
-
this._globalLogLevel = this._logLevelSet.has(
|
|
1269
|
+
this._globalLogLevel = this._logLevelSet.has(levelStr) ? levelStr : this._globalLogLevel;
|
|
1270
1270
|
this._globalLogLevelNumber = this._logLevelValues.indexOf(this._globalLogLevel);
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
@@ -1425,8 +1425,9 @@ var LogM8 = class {
|
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
1427
|
_setLevel(logger, level) {
|
|
1428
|
-
|
|
1429
|
-
logger.
|
|
1428
|
+
const levelStr = (level ?? "").trim().toLowerCase();
|
|
1429
|
+
logger.level = this._logLevelSet.has(levelStr) ? levelStr : logger.level;
|
|
1430
|
+
logger._levelNumber = this._logLevelValues.indexOf(logger.level);
|
|
1430
1431
|
logger.isEnabled = logger.level !== LogLevel.off;
|
|
1431
1432
|
const levelNumber = logger._levelNumber;
|
|
1432
1433
|
logger.isFatal = this._logLevelValues.indexOf(LogLevel.fatal) <= levelNumber;
|
|
@@ -1480,12 +1481,52 @@ var LogM8 = class {
|
|
|
1480
1481
|
}
|
|
1481
1482
|
};
|
|
1482
1483
|
|
|
1484
|
+
// src/NullLogger.ts
|
|
1485
|
+
var NullLogger = class {
|
|
1486
|
+
constructor() {
|
|
1487
|
+
__publicField(this, "isFatal", false);
|
|
1488
|
+
__publicField(this, "isError", false);
|
|
1489
|
+
__publicField(this, "isWarn", false);
|
|
1490
|
+
__publicField(this, "isInfo", false);
|
|
1491
|
+
__publicField(this, "isDebug", false);
|
|
1492
|
+
__publicField(this, "isTrack", false);
|
|
1493
|
+
__publicField(this, "isTrace", false);
|
|
1494
|
+
__publicField(this, "isEnabled", false);
|
|
1495
|
+
__publicField(this, "name", "nullLogger");
|
|
1496
|
+
__publicField(this, "level", "off");
|
|
1497
|
+
__publicField(this, "context", {});
|
|
1498
|
+
}
|
|
1499
|
+
fatal(_message, ..._args) {
|
|
1500
|
+
}
|
|
1501
|
+
error(_message, ..._args) {
|
|
1502
|
+
}
|
|
1503
|
+
warn(_message, ..._args) {
|
|
1504
|
+
}
|
|
1505
|
+
info(_message, ..._args) {
|
|
1506
|
+
}
|
|
1507
|
+
debug(_message, ..._args) {
|
|
1508
|
+
}
|
|
1509
|
+
track(_message, ..._args) {
|
|
1510
|
+
}
|
|
1511
|
+
trace(_message, ..._args) {
|
|
1512
|
+
}
|
|
1513
|
+
setLevel(_level) {
|
|
1514
|
+
}
|
|
1515
|
+
setContext(context) {
|
|
1516
|
+
this.context = context;
|
|
1517
|
+
}
|
|
1518
|
+
getLogger(_name) {
|
|
1519
|
+
return this;
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1483
1523
|
// src/index.ts
|
|
1484
1524
|
var LogM82 = new LogM8();
|
|
1485
1525
|
export {
|
|
1486
1526
|
LogLevel,
|
|
1487
1527
|
LogM82 as LogM8,
|
|
1488
1528
|
LogM8Utils,
|
|
1529
|
+
NullLogger,
|
|
1489
1530
|
PluginKind
|
|
1490
1531
|
};
|
|
1491
1532
|
//# sourceMappingURL=index.js.map
|