Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
*.log
.DS_Store
*/skills/metaskills
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
*.log
.DS_Store
*/skills/metaskills
22 changes: 13 additions & 9 deletions metalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ class Console {
}

count(label = 'default') {
let cnt = this.#counts.get(label) || 0;
cnt++;
this.#counts.set(label, cnt);
this.#logger.write('debug', this.#groupIndent, [`${label}: ${cnt}`]);
const current = this.#counts.get(label) || 0;
const countValue = current + 1;
this.#counts.set(label, countValue);
this.#logger.write('debug', this.#groupIndent, [`${label}: ${countValue}`]);
}

countReset(label = 'default') {
Expand All @@ -268,8 +268,8 @@ class Console {

trace(...args) {
const msg = util.format(...args);
const err = new Error(msg);
this.#logger.write('debug', this.#groupIndent, [`Trace${err.stack}`]);
const error = new Error(msg);
this.#logger.write('debug', this.#groupIndent, [`Trace${error.stack}`]);
}

info(...args) {
Expand Down Expand Up @@ -439,9 +439,13 @@ class Logger extends EventEmitter {
this.emit('close');
try {
const stats = await fsp.stat(this.#file);
if (stats.size === 0) await fsp.unlink(this.#file).catch(() => {});
} catch {
this.emit('error', new Error(`Can't delete log file: ${this.#file}`));
if (stats.size === 0) {
await fsp.unlink(this.#file).catch((error) => {
this.emit('error', error);
});
}
} catch (error) {
this.emit('error', error);
}
}

Expand Down
54 changes: 34 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
},
"dependencies": {
"concolor": "^1.1.4",
"metautil": "^5.5.1"
"metautil": "^5.5.2"
},
"devDependencies": {
"@types/node": "^25.4.0",
"@types/node": "^25.5.0",
"eslint": "^9.39.4",
"eslint-config-metarhia": "^9.1.8",
"metaskills": "^1.0.3",
"prettier": "^3.7.4",
"typescript": "^5.9.2"
}
Expand Down
4 changes: 2 additions & 2 deletions test/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const run = async () => {
});

test('console.error', () => {
const err = new Error('Test log message for console.error');
console.error(err);
const error = new Error('Test log message for console.error');
console.error(error);
});

test('console.group', () => {
Expand Down
Loading