Skip to content

Commit

Permalink
changing the name
Browse files Browse the repository at this point in the history
  • Loading branch information
carvilsi committed Mar 28, 2024
1 parent 27edcbd commit 0c5ac3d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
4 changes: 2 additions & 2 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint no-console: "off" */

import { Bench } from 'tinybench';
import { SysLogger } from './../src/index.js';
import { SysDLogger } from './../src/sysdlogger.js';
import { randomUUID } from 'node:crypto';

const bench = new Bench({ time: 100 });

const TAG = `NODE_SYSTEMD_JOURNAL_${randomUUID()}`;
const MESSAGE = 'a foo at the bar for lol';
const CUSTOM_TAG = 'foobar';
const syslogger = new SysLogger({ tag: TAG });
const syslogger = new SysDLogger({ tag: TAG });

(async() => {
bench
Expand Down
24 changes: 12 additions & 12 deletions benchmark/report.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
┌─────────┬──────────────────────────────────────────────────────────────────────────────────┬─────────┬───────────────────┬───────────┬─────────┐
│ (index) │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │
├─────────┼──────────────────────────────────────────────────────────────────────────────────┼─────────┼───────────────────┼───────────┼─────────┤
│ 0 │ 'add an entry to systemd-journal' │ '326' │ 3061132.12121213 │ '±24.78%' │ 33
│ 1 │ 'add an entry to systemd-journal with a custom tag' │ '385' │ 2596141.9487179583 │ '±6.41%' │ 39
│ 2 │ 'retrieve an entry from systemd-journal' │ '165' │ 6034642.294117662 │ '±23.69%' │ 17
│ 3 │ 'retrieve an entry from systemd-journal by custom tag' │ '118' │ 8463967.076923102 │ '±22.58%' │ 13
│ 4 │ 'retrieve an entry from systemd-journal by tag in JSON format' │ '118' │ 8466418.384615403 │ '±28.61%' │ 13
│ 5 │ 'retrieve 2 lines from systemd-journal' │ '138' │ 7212675.3571428545 │ '±24.41%' │ 14 │
│ 6 │ 'retrieve lines in reverse mode from systemd-journal' │ '152' │ 6570073.187499972 │ '±22.28%' │ 16
│ 7 │ 'retrieve 2 entries from systemd-journal by tag in JSON format and reverse mode' │ '119' │ 8344566.083333327 │ '±30.89%' │ 12
└─────────┴──────────────────────────────────────────────────────────────────────────────────┴─────────┴───────────────────┴───────────┴─────────┘
┌─────────┬──────────────────────────────────────────────────────────────────────────────────┬─────────┬───────────────────┬───────────┬─────────┐
│ (index) │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │
├─────────┼──────────────────────────────────────────────────────────────────────────────────┼─────────┼───────────────────┼───────────┼─────────┤
│ 0 │ 'add an entry to systemd-journal' │ '145' │ 6866412.733333331 │ '±23.98%' │ 15
│ 1 │ 'add an entry to systemd-journal with a custom tag' │ '213' │ 4676238.772727258 │ '±49.87%' │ 22
│ 2 │ 'retrieve an entry from systemd-journal' │ '131' │ 7581218.428571397 │ '±34.56%' │ 14
│ 3 │ 'retrieve an entry from systemd-journal by custom tag' │ '109' │ 9165432.363636393 │ '±27.75%' │ 11
│ 4 │ 'retrieve an entry from systemd-journal by tag in JSON format' │ '81' │ 12321908.00000003 │ '±36.07%' │ 10
│ 5 │ 'retrieve 2 lines from systemd-journal' │ '138' │ 7240714.857142865 │ '±21.18%' │ 14 │
│ 6 │ 'retrieve lines in reverse mode from systemd-journal' │ '142' │ 7041945.066666691 │ '±19.72%' │ 15
│ 7 │ 'retrieve 2 entries from systemd-journal by tag in JSON format and reverse mode' │ '136' │ 7352763.642857147 │ '±19.28%' │ 14
└─────────┴──────────────────────────────────────────────────────────────────────────────────┴─────────┴───────────────────┴───────────┴─────────┘
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "node-systemd-journal",
"name": "sysdlogger",
"version": "1.0.0",
"description": "",
"main": "./src/index.js",
"main": "./src/sysdlogger.js",
"type": "module",
"exports": "./src/index.js",
"exports": "./src/sysdlogger.js",
"scripts": {
"test": "npm run lint && npm run lint-test && npm run test-src",
"test-src": "./node_modules/c8/bin/c8.js ava",
Expand All @@ -20,6 +20,10 @@
"pre-release": "npm audit && ./pre-release.sh",
"release": "tag=$(node -e \"console.log(require('./package.json').version)\"); git tag v${tag}; git push origin v${tag} && npm publish"
},
"repository": {
"type": "git",
"url": "https://github.com/carvilsi/node-systemd-journal"
},
"keywords": [
"systemd",
"nodejs",
Expand All @@ -28,7 +32,7 @@
"logger",
"journalctl"
],
"author": "char@omg.lol",
"author": "carvilsi@gmail.com",
"license": "MIT",
"devDependencies": {
"ava": "^6.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js → src/sysdlogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { toJSONArray, checkPlatform } from './util.js';

const exec = util.promisify(child_process.exec);

export class SysLogger {
export class SysDLogger {
options = {
tag: this.constructor.name,
json: false,
Expand Down
10 changes: 5 additions & 5 deletions tests/main.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import test from 'ava';
import { randomUUID } from 'node:crypto';
import { SysLogger } from '../src/index.js';
import { SysDLogger } from '../src/sysdlogger.js';

const MESSAGE = 'a foo in tha bar for lol';
const TAG = `NODE_SYSTEMD_JOURNAL_${randomUUID()}`;
const ERROR_MESSAGE = '\'message\' parameter is mandatory and must be a string';

const syslogger = new SysLogger({ tag: TAG });
const syslogger = new SysDLogger({ tag: TAG });

test('should throws an error', async(t) => {
await t.throwsAsync(async() => {
Expand Down Expand Up @@ -110,7 +110,7 @@ test.serial('should retrieve two lines of log on JSON format and reverse mode',
test('should use the defatult tag if is not provided ' +
'when creating the instance',
async(t) => {
const sjournal = new SysLogger();
const sjournal = new SysDLogger();
const message = 'a logger entry without custom tag';
await sjournal.write(message);
const lines = await sjournal.read({ json: true, lines: 1 });
Expand All @@ -122,7 +122,7 @@ async(t) => {

test('should use the defatult tag if is empty when creating the instance',
async(t) => {
const sjournal = new SysLogger({ tag: '', json: true, lines: 1 });
const sjournal = new SysDLogger({ tag: '', json: true, lines: 1 });
const message = 'a logger entry without custom tag';
await sjournal.write(message);
const lines = await sjournal.read();
Expand All @@ -135,7 +135,7 @@ test('should use the defatult tag if is empty when creating the instance',
test('should use the defatult tag if consists on spaces when ' +
'creating the instance',
async(t) => {
const sjournal = new SysLogger({ tag: ' ', json: true, lines: 1 });
const sjournal = new SysDLogger({ tag: ' ', json: true, lines: 1 });
const message = 'a logger entry without custom tag';
await sjournal.write(message);
const lines = await sjournal.read();
Expand Down

0 comments on commit 0c5ac3d

Please sign in to comment.