logixlysia 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/logger.ts +12 -5
- package/src/types.ts +4 -2
- package/test/logixlysia.test.ts +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.0.2](https://github.com/PunGrumpy/logixlysia/compare/v3.0.1...v3.0.2) (2024-04-08)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **logger:** add `config` property for logging configuration ([27d80eb](https://github.com/PunGrumpy/logixlysia/commit/27d80eb6b0c3a4a40a96738b235d9bc6b117c804))
|
|
9
|
+
|
|
3
10
|
## [3.0.1](https://github.com/PunGrumpy/logixlysia/compare/v3.0.0...v3.0.1) (2024-04-08)
|
|
4
11
|
|
|
5
12
|
|
package/package.json
CHANGED
package/src/logger.ts
CHANGED
|
@@ -4,8 +4,15 @@ import methodString from './utils/method'
|
|
|
4
4
|
import logString from './utils/log'
|
|
5
5
|
import pathString from './utils/path'
|
|
6
6
|
import statusString from './utils/status'
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
LogLevel,
|
|
9
|
+
LogData,
|
|
10
|
+
Logger,
|
|
11
|
+
StoreData,
|
|
12
|
+
Options,
|
|
13
|
+
RequestInfo,
|
|
14
|
+
HttpError
|
|
15
|
+
} from './types'
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
18
|
* Logs a message.
|
|
@@ -52,12 +59,12 @@ function buildLogMessage(
|
|
|
52
59
|
const statusStr = statusString(data.status || 200)
|
|
53
60
|
const messageStr = data.message || ''
|
|
54
61
|
const ipStr =
|
|
55
|
-
options?.ip && request.headers.get('x-forwarded-for')
|
|
62
|
+
options?.config?.ip && request.headers.get('x-forwarded-for')
|
|
56
63
|
? `IP: ${request.headers.get('x-forwarded-for')}`
|
|
57
64
|
: ''
|
|
58
65
|
|
|
59
66
|
const logFormat =
|
|
60
|
-
options?.customLogFormat ||
|
|
67
|
+
options?.config?.customLogFormat ||
|
|
61
68
|
'🦊 {now} {level} {duration} {method} {pathname} {status} {message} {ip}'
|
|
62
69
|
const logMessage = logFormat
|
|
63
70
|
.replace('{now}', nowStr)
|
|
@@ -81,7 +88,7 @@ function buildLogMessage(
|
|
|
81
88
|
export const createLogger = (options?: Options): Logger => ({
|
|
82
89
|
log: (level, request, data, store) =>
|
|
83
90
|
log(level, request, data, store, options),
|
|
84
|
-
customLogFormat: options?.customLogFormat
|
|
91
|
+
customLogFormat: options?.config?.customLogFormat
|
|
85
92
|
})
|
|
86
93
|
|
|
87
94
|
/**
|
package/src/types.ts
CHANGED
package/test/logixlysia.test.ts
CHANGED
|
@@ -12,9 +12,11 @@ describe('Logixlysia with IP logging enabled', () => {
|
|
|
12
12
|
server = new Elysia()
|
|
13
13
|
.use(
|
|
14
14
|
logger({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
config: {
|
|
16
|
+
ip: true,
|
|
17
|
+
customLogFormat:
|
|
18
|
+
'🦊 {now} {duration} {level} {method} {pathname} {status} {message} {ip}'
|
|
19
|
+
}
|
|
18
20
|
})
|
|
19
21
|
)
|
|
20
22
|
.get('/', ctx => {
|
|
@@ -69,9 +71,11 @@ describe('Logixlysia with IP logging disabled', () => {
|
|
|
69
71
|
server = new Elysia()
|
|
70
72
|
.use(
|
|
71
73
|
logger({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
config: {
|
|
75
|
+
ip: false,
|
|
76
|
+
customLogFormat:
|
|
77
|
+
'🦊 {now} {duration} {level} {method} {pathname} {status} {message} {ip}'
|
|
78
|
+
}
|
|
75
79
|
})
|
|
76
80
|
)
|
|
77
81
|
.get('/', () => '🦊 Logixlysia Getting')
|