logixlysia 3.0.0 → 3.0.1

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 CHANGED
@@ -1,11 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.0.1](https://github.com/PunGrumpy/logixlysia/compare/v3.0.0...v3.0.1) (2024-04-08)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **logger:** use correct status code in error log message ([a3ec49c](https://github.com/PunGrumpy/logixlysia/commit/a3ec49cd3fc1dc7f01a29b21e4de9cf543329c43)), closes [#33](https://github.com/PunGrumpy/logixlysia/issues/33)
9
+
3
10
  ## [3.0.0](https://github.com/PunGrumpy/logixlysia/compare/v2.3.1...v3.0.0) (2024-04-08)
4
11
 
5
12
 
6
13
  ### ⚠ BREAKING CHANGES
7
14
 
8
- * **options:**
15
+ * Added support for custom log format in the logger
16
+ * Enhanced flexibility for define thier preferred log message structure
9
17
 
10
18
  ### Features
11
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "logixlysia",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "🦊 Logixlysia is a logger for Elysia",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ import Elysia from 'elysia'
2
2
  import { createLogger, handleHttpError } from './logger'
3
3
  import startString from './utils/start'
4
4
  import { Server } from 'bun'
5
- import { Options } from './types'
5
+ import { HttpError, Options } from './types'
6
6
 
7
7
  /**
8
8
  * Creates a logger.
@@ -35,7 +35,12 @@ export const logger = (options?: Options): Elysia => {
35
35
  log.log('INFO', request, { status: 200 }, store as { beforeTime: bigint })
36
36
  })
37
37
  .onError({ as: 'global' }, ({ request, error, store }) => {
38
- handleHttpError(request, error, store as { beforeTime: bigint })
38
+ handleHttpError(
39
+ request,
40
+ error as HttpError,
41
+ store as { beforeTime: bigint },
42
+ options
43
+ )
39
44
  })
40
45
 
41
46
  return elysia
package/src/logger.ts CHANGED
@@ -88,17 +88,17 @@ export const createLogger = (options?: Options): Logger => ({
88
88
  * Handles an HTTP error.
89
89
  *
90
90
  * @param {RequestInfo} request The request.
91
- * @param {Error} error The error.
91
+ * @param {HttpError} error The HTTP error.
92
92
  * @param {StoreData} store The store data.
93
93
  * @param {Options} options The options.
94
94
  */
95
95
  export const handleHttpError = (
96
96
  request: RequestInfo,
97
- error: Error,
97
+ error: HttpError,
98
98
  store: StoreData,
99
99
  options?: Options
100
100
  ): void => {
101
- const statusCode = error instanceof HttpError ? error.status : 500
101
+ const statusCode = error.status || 500
102
102
  const logMessage = buildLogMessage(
103
103
  'ERROR',
104
104
  request,