Why did I need that?
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"test-conversion": "deno run -A tests/convert.ts",
|
||||
"test-global": "deno run -A tests/global.ts",
|
||||
"test-timing": "deno run -A tests/timing.ts",
|
||||
"test-basic": "deno run -A tests/basic.ts",
|
||||
"bench": "deno bench -A"
|
||||
},
|
||||
"imports": {
|
||||
@@ -10,7 +11,7 @@
|
||||
"chalk": "npm:chalk@^5.3.0"
|
||||
},
|
||||
"exports": "./mod.ts",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"name": "@proxnet/undead-logging",
|
||||
"license": "MIT",
|
||||
"bench": {
|
||||
|
||||
12
mod.ts
12
mod.ts
@@ -22,9 +22,6 @@ interface LoggingOptions {
|
||||
/** Control all log sources from this module */
|
||||
const sources: Set<Logging> = new Set();
|
||||
|
||||
/** The first log message across all sources will not contain carriage return + newline control codes */
|
||||
let first = true;
|
||||
|
||||
/**
|
||||
* A source for pretty and cool and fun logging
|
||||
*/
|
||||
@@ -175,18 +172,13 @@ class Logging {
|
||||
const str = this.#conversions(...msgs);
|
||||
const msg = `${chalk.gray(this.#timeStr(time))} ${chalkColor(chalk.inverse(`${this.source} ${this.#typeStr(type)}`) + ` ${str}`)}`
|
||||
|
||||
process.stdout.write(`${first ? '' : '\r\n'}${msg}`);
|
||||
// I don't know if promise-ifying this helps or not.
|
||||
// deno-lint-ignore require-await
|
||||
(async () => {
|
||||
first = false;
|
||||
})();
|
||||
process.stdout.write(`${msg}\r\n`);
|
||||
|
||||
try {
|
||||
LoggingListeners.emit('basic', msg);
|
||||
LoggingListeners.emit('type', str, type, this.source, time);
|
||||
} catch (err) {
|
||||
process.stderr.write(`\r\n(FALLBACK ERROR) Callback failed! Stack: ${(err as Error).stack}`);
|
||||
process.stderr.write(`(FALLBACK ERROR) Callback failed! Stack: ${(err as Error).stack}\r\n`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
7
tests/basic.ts
Normal file
7
tests/basic.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import Logging from "@proxnet/undead-logging";
|
||||
|
||||
const log = new Logging("Test");
|
||||
|
||||
log.i('Hello World! 1');
|
||||
log.d('Hello World! 2');
|
||||
log.n('Hello World! 3');
|
||||
Reference in New Issue
Block a user