Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ekino/logger v3.0 #48

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
4566757
chore(yarn): use yarn v2
tduyng Oct 21, 2024
0152daa
chore(hooks): remove husky, use native githooks
tduyng Oct 21, 2024
999ed77
chore(deps): use exact version of dev dependencies for better local dev
tduyng Oct 21, 2024
e7db6b8
chore(lint): implement biome and remove eslint,prettier
tduyng Oct 21, 2024
011198e
fix(lint): fix all linter issues
tduyng Oct 21, 2024
bc3100c
refactor(outils): remove unused function
tduyng Oct 21, 2024
94c17cb
refactor: write native colors outils
tduyng Oct 21, 2024
f1fd5e1
refactor(examples): give meaningfull messages
tduyng Oct 22, 2024
f9a94a0
chore(deps): remove unused eslint and prettier
tduyng Oct 22, 2024
8b83f9f
refactor(adapters): create wrapper writable stream for process.stdout…
tduyng Oct 22, 2024
10d473a
feat(perf): implement fast-json-stringify for better performance json…
tduyng Oct 22, 2024
245729d
refactor: implement pur functional, avoid mutable internal object
tduyng Oct 22, 2024
eac80d7
refactor: separate default config and mutual config
tduyng Oct 22, 2024
4d6b3d1
fix: handle correctly dual signature for logMethod
tduyng Oct 22, 2024
8d64d9f
feat(perf): implement memorization for caching expensive operations
tduyng Oct 22, 2024
afd4099
refactor: separate json schema for fast-json-stringify
tduyng Oct 22, 2024
ccbb2c6
fix: fast-json-stringify do not support replacer
tduyng Oct 22, 2024
eb0efdc
feat(3.0): convert src code to ESM
tduyng Oct 26, 2024
dfe49fb
feat(3.0): remove ts-node, use tsx, convert examples to typescript
tduyng Oct 26, 2024
109b4e1
chore(3.0): ignore format package.json by biome
tduyng Oct 26, 2024
efb6522
feat(3.0): support more colors
tduyng Oct 26, 2024
70735b5
chore(3.0): support dual npm package in ESM and CJS
tduyng Oct 26, 2024
3a0f647
chore(3.0): set Node.js 18 as the minimum supported version
tduyng Oct 26, 2024
53d8730
chore(3.0): remove unused Makefile
tduyng Oct 26, 2024
47c134a
ci(3.0): fix, update action versions, run test on Nodejs18,20,22
tduyng Oct 26, 2024
2afacab
ci(3.0): simplify release step and build Typescript files
tduyng Oct 26, 2024
5ac9e32
chore(3.0): run examples/*.ts with deno for faster execution
tduyng Oct 26, 2024
8d79fb5
chore(3.0): remove unused dependencies
tduyng Oct 26, 2024
2a886fc
chore(3.0): add more tags
tduyng Oct 26, 2024
9effe33
ci(3.0): add issue templates: bug, feature_request
tduyng Oct 26, 2024
37a4acb
docs(3.0): update image examples
tduyng Oct 26, 2024
2ccdde4
test(3.0): rewrite tests with vitest for ESM
tduyng Oct 26, 2024
291740b
test(3.0): reimplement coverage with vitest + c8
tduyng Oct 26, 2024
28261c4
feat(3.0): use native crypto.randomUUID to replace uuidV4
tduyng Oct 26, 2024
06de2a3
test(3.0): rewrite all test files in Typescript with vitest
tduyng Oct 27, 2024
252493e
chore(3.0): cleanup package.json
tduyng Oct 28, 2024
92fdfd5
docs(3.0): update documentations
tduyng Oct 28, 2024
0af815e
chore(3.0): add CONTRIBUTION rules
tduyng Oct 28, 2024
cfd1858
docs(3.0): add breaking change docs
tduyng Oct 28, 2024
708b16f
ci(3.0): add type checking step
tduyng Oct 28, 2024
cbee334
docs(3.0): create benchmark with v2, winston and pino
tduyng Oct 28, 2024
61decaf
perf(3.0): early return log when not forcing and not active level
tduyng Oct 28, 2024
783a6a8
perf(3.0): avoid using Object.assign
tduyng Oct 28, 2024
2087ee3
docs(3.0): add benchmarks results
tduyng Oct 28, 2024
1c68174
chore(3.0): add benchmark for complex objects
tduyng Oct 29, 2024
7686758
chore(3.0): simplify and split and create helpers functions for bench…
tduyng Oct 29, 2024
7632fbb
chore(3.0): remove tsx, write build script directly in js
tduyng Oct 30, 2024
42164ed
chore(3.0): off useImportType lint rule
tduyng Nov 20, 2024
bbef8d2
test(3.0): use correct type MockInstance for vi.spyOn
tduyng Nov 20, 2024
92c563e
ci(3.0): implement git cliff for highly customizable changelog
tduyng Nov 27, 2024
434899d
chore(3.0): update the dev dependencies
tduyng Nov 27, 2024
7ecafb4
chore(3.0): replace yarn by pnpm
tduyng Feb 6, 2025
2f12694
chore(3.0): upgrade dev dependencies
tduyng Feb 6, 2025
92d8ad5
feat(3.0): remove fast-json-stringify
tduyng Feb 6, 2025
06627ef
chore(3.0): simplify build scripts
tduyng Feb 6, 2025
778db14
chore(deps): update latest dependencies
tduyng Feb 17, 2025
d0f73e6
ci: setup bot user for creating release commit
tduyng Feb 17, 2025
8392aa3
ci: simplify bump version and tag with npm
tduyng Feb 17, 2025
90d1bd9
feat: use @tduyng/prettyouput to replace deprecated prettyoutput library
tduyng Feb 17, 2025
6780446
docs: update README.md
tduyng Feb 17, 2025
a933b2f
chore(deps): use major version for dependencies field
tduyng Feb 18, 2025
ef6856e
ci: check typings for all files
tduyng Feb 18, 2025
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
Prev Previous commit
Next Next commit
docs(3.0): create benchmark with v2, winston and pino
tduyng committed Oct 28, 2024
commit cbee33437a453f55a9a63b42058d0536bba65bda
13 changes: 13 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# BENCHMARKS

- Tested on Nodejs 22.8.0
```bash
┌─────────┬──────────────────────┬───────────┐
│ (index) │ library │ ops/sec │
├─────────┼──────────────────────┼───────────┤
│ 0 │ 'Pino' │ '181,851' │
│ 1 │ '@ekino/logger v3.x' │ '160,179' │
│ 2 │ '@ekino/logger v2.x' │ '136,705' │
│ 3 │ 'Winston' │ '86,693' │
└─────────┴──────────────────────┴───────────┘
```
83 changes: 83 additions & 0 deletions benchmarks/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env node

import * as logger2 from '@ekino/logger'
import { Suite } from '@jonahsnider/benchmark'
import pino from 'pino'
import * as winston from 'winston'
import * as logger3 from '../lib/esm/index.js'

const suite = new Suite('Logger Benchmark', {
warmup: { trials: 3000 }, // Run benchmark for 3000ms
run: { trials: 10_000 }, // Run 1000 warmup trials
})

// Initialize loggers
logger2.setLevel('info')
logger3.setLevel('info')

const ekinoLoggerV2 = logger2.createLogger('benchmark')
const ekinoLoggerV3 = logger3.createLogger('benchmark')
const pinoLogger = pino({
level: 'info',
prettyPrint: false,
destination: pino.destination({ sync: true }), // Synced JSON output
})
const winstonLogger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [new winston.transports.Console()],
})

const message = 'This is a benchmark log message'
const logObject = {
user: 'John Doe',
action: 'Test Action',
timestamp: new Date(),
details: {
ipAddress: '192.168.1.1',
location: 'New York',
permissions: ['read', 'write', 'admin'],
metadata: { session: 'abcdef12345', retries: 2 },
},
}
const contextId = 'a037df3b-dbee-448e-9abb-8024d867ccc8'

async function runBenchmarks() {
suite
.addTest('@ekino/logger v2.x', () => {
ekinoLoggerV2.info(contextId, message, logObject)
})
.addTest('@ekino/logger v3.x', () => {
ekinoLoggerV3.info(contextId, message, logObject)
})
.addTest('Winston', () => {
winstonLogger.info(message, logObject)
})
.addTest('Pino', () => {
pinoLogger.info({
ctxId: contextId,
...logObject,
message,
})
})

const results = await suite.run()
return results
}

const results = await runBenchmarks()

const table = [...results]
.map(([library, histogram]) => [
library,
Math.round(1e9 / histogram.percentile(50)), // Median to ops/sec
])
.sort(([, a], [, b]) => b - a)
.map(([library, opsPerSec]) => ({
library,
'ops/sec': opsPerSec.toLocaleString(),
}))

setTimeout(() => {
console.table(table)
}, 5000)
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -50,13 +50,17 @@
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@ekino/logger": "2.1.1",
"@jonahsnider/benchmark": "^5.1.1",
"@types/node": "22.7.7",
"@vitest/coverage-v8": "2.1.3",
"commitlint": "19.5.0",
"conventional-changelog-cli": "5.0.0",
"pino": "^9.5.0",
"tsx": "^4.19.1",
"typescript": "5.6.3",
"vitest": "^2.1.3"
"vitest": "^2.1.3",
"winston": "^3.15.0"
},
"scripts": {
"lint": "biome check --write",
998 changes: 656 additions & 342 deletions yarn.lock

Large diffs are not rendered by default.