breaking change. it works better.

This commit is contained in:
2026-01-04 19:28:56 -05:00
parent 6a7c6eb40b
commit df31d60af9
15 changed files with 635 additions and 823 deletions

View File

@@ -1,16 +1,14 @@
import Logging, { LoggingListeners } from "../mod.ts";
import process from "node:process";
import Logging, { LoggingConfiguration, LoggingListeners } from "../src/mod.ts";
const debug = process.argv[process.argv.length - 1] == 'true';
const debug = Deno.args[Deno.args.length - 1] === 'true';
console.debug(`Debug mode: ${debug}`);
const changeTimeFormat = process.argv[process.argv.length - 2] == 'true';
console.debug(`changeTimeFormat: ${changeTimeFormat}`);
if (debug) {
LoggingListeners.onmsg('basic', msg => {
console.debug(`\r\n[d] ${msg}`);
console.debug(`[d] ${msg}`);
});
LoggingListeners.onmsg('type', (msg, type, source, time) => {
console.debug(`[D] M:'${msg}' T:${type} S:'${source}' TM:${time.getTime()}`);
console.debug(`[D] M:'${msg}' T:${type} S:'${source}' TM:${time.getTime()}${Logging.getNewline()}`);
});
}
@@ -18,4 +16,25 @@ const webLog = new Logging("Web");
webLog.d(`Following is a Request`);
webLog.i(new Request('http://example.com?hello=world', { headers: { 'key1': 'value1', 'key2': 'value2' }}));
webLog.d(`Following is a Response`);
webLog.i(await fetch('https://example.com'));
webLog.i(await fetch('https://example.com'));
class CustomClass {
foo: string;
bar: number;
constructor(foo: string, bar: number) {
this.foo = foo;
this.bar = bar;
}
}
LoggingConfiguration.addConversion<CustomClass>({
condition: arg => arg instanceof CustomClass,
converter: arg => `CustomClass; foo:${arg.foo}; bar:${arg.bar};`
});
const log = new Logging("ConvertTest");
log.d(new CustomClass("baz", 39));