@pori15/logixlysia 6.0.1 → 6.0.3

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/src/interfaces.ts CHANGED
@@ -1,145 +1,138 @@
1
- import type {
2
- Logger as PinoLogger,
3
- LoggerOptions as PinoLoggerOptions
4
- } from 'pino'
5
- import { ProblemError } from './Error/errors'
6
- import { Code } from './Error/type'
7
-
8
- export type Pino = PinoLogger<never, boolean>
9
- export type Request = Request
10
-
11
- export type RequestInfo = Request
12
-
13
- export type LogLevel = 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR'
14
-
15
- export interface StoreData {
16
- beforeTime: bigint
17
- }
18
-
19
- export interface LogixlysiaStore {
20
- logger: Logger
21
- pino: Pino
22
- beforeTime?: bigint
23
- [key: string]: unknown
24
- }
25
-
26
- export interface Transport {
27
- log: (
28
- level: LogLevel,
29
- message: string,
30
- meta?: Record<string, unknown>
31
- ) => void | Promise<void>
32
- }
33
-
34
- export interface LogRotationConfig {
35
- /**
36
- * Max log file size before rotation, e.g. '10m', '5k', or a byte count.
37
- */
38
- maxSize?: string | number
39
- /**
40
- * Keep at most N files or keep files for a duration like '7d'.
41
- */
42
- maxFiles?: number | string
43
- /**
44
- * Rotate at a fixed interval, e.g. '1d', '12h'.
45
- */
46
- interval?: string
47
- compress?: boolean
48
- compression?: 'gzip'
49
- }
50
-
51
- export interface LogFilter {
52
- /**
53
- * Array of log levels to allow. If specified, only logs with these levels will be processed.
54
- * If not specified, all log levels will be allowed.
55
- */
56
- level?: LogLevel[]
57
- }
58
-
59
- export interface Options {
60
- config?: {
61
- showStartupMessage?: boolean
62
- startupMessageFormat?: 'simple' | 'banner'
63
- useColors?: boolean
64
- ip?: boolean
65
- timestamp?: {
66
- translateTime?: string
67
- }
68
- customLogFormat?: string
69
-
70
- // Filtering
71
- logFilter?: LogFilter
72
-
73
- // Outputs
74
- transports?: Transport[]
75
- useTransportsOnly?: boolean
76
- disableInternalLogger?: boolean
77
- disableFileLogging?: boolean
78
- logFilePath?: string
79
- logRotation?: LogRotationConfig
80
-
81
- // Pino
82
- pino?: (PinoLoggerOptions & { prettyPrint?: boolean }) | undefined
83
-
84
- error?:{
85
- problemJson?:{
86
- typeBaseUrl?: string
87
- }
88
- }
89
-
90
- }
91
-
92
- transform?: (error: unknown, context: { request: Request; code: Code }) => ProblemError | unknown
93
-
94
-
95
- }
96
-
97
- export class HttpError extends Error {
98
- readonly status: number
99
-
100
- constructor(status: number, message: string) {
101
- super(message)
102
- this.status = status
103
- }
104
- }
105
-
106
- export interface Logger {
107
- pino: Pino
108
- log: (
109
- level: LogLevel,
110
- request: Request,
111
- data: Record<string, unknown>,
112
- store: StoreData
113
- ) => void
114
- handleHttpError: (
115
- request: Request,
116
- error: ProblemError,
117
- store: StoreData,
118
- options: Options
119
- ) => void
120
- debug: (
121
- request: Request,
122
- message: string,
123
- context?: Record<string, unknown>
124
- ) => void
125
- info: (
126
- request: Request,
127
- message: string,
128
- context?: Record<string, unknown>
129
- ) => void
130
- warn: (
131
- request: Request,
132
- message: string,
133
- context?: Record<string, unknown>
134
- ) => void
135
- error: (
136
- request: Request,
137
- message: string,
138
- context?: Record<string, unknown>
139
- ) => void
140
- }
141
-
142
- export interface LogixlysiaContext {
143
- request: Request
144
- store: LogixlysiaStore
145
- }
1
+ import type {
2
+ Logger as PinoLogger,
3
+ LoggerOptions as PinoLoggerOptions
4
+ } from 'pino'
5
+ import type { ProblemError } from './Error/errors'
6
+ import type { Code } from './Error/type'
7
+
8
+ export type Pino = PinoLogger<never, boolean>
9
+
10
+
11
+ export type RequestInfo = Request
12
+
13
+ export type LogLevel = 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR'
14
+
15
+ export interface StoreData {
16
+ beforeTime: bigint
17
+ }
18
+
19
+ export interface LogixlysiaStore {
20
+ logger: Logger
21
+ pino: Pino
22
+ beforeTime?: bigint
23
+ [key: string]: unknown
24
+ }
25
+
26
+ export interface Transport {
27
+ log: (
28
+ level: LogLevel,
29
+ message: string,
30
+ meta?: Record<string, unknown>
31
+ ) => void | Promise<void>
32
+ }
33
+
34
+ export interface LogRotationConfig {
35
+ /**
36
+ * Max log file size before rotation, e.g. '10m', '5k', or a byte count.
37
+ */
38
+ maxSize?: string | number
39
+ /**
40
+ * Keep at most N files or keep files for a duration like '7d'.
41
+ */
42
+ maxFiles?: number | string
43
+ /**
44
+ * Rotate at a fixed interval, e.g. '1d', '12h'.
45
+ */
46
+ interval?: string
47
+ compress?: boolean
48
+ compression?: 'gzip'
49
+ }
50
+
51
+ export interface LogFilter {
52
+ /**
53
+ * Array of log levels to allow. If specified, only logs with these levels will be processed.
54
+ * If not specified, all log levels will be allowed.
55
+ */
56
+ level?: LogLevel[]
57
+ }
58
+
59
+ export interface Options {
60
+ config?: {
61
+ showStartupMessage?: boolean
62
+ startupMessageFormat?: 'simple' | 'banner'
63
+ useColors?: boolean
64
+ ip?: boolean
65
+ timestamp?: {
66
+ translateTime?: string
67
+ }
68
+ customLogFormat?: string
69
+
70
+ // Filtering
71
+ logFilter?: LogFilter
72
+
73
+ // Outputs
74
+ transports?: Transport[]
75
+ useTransportsOnly?: boolean
76
+ disableInternalLogger?: boolean
77
+ disableFileLogging?: boolean
78
+ logFilePath?: string
79
+ logRotation?: LogRotationConfig
80
+
81
+ // Pino
82
+ pino?: (PinoLoggerOptions & { prettyPrint?: boolean }) | undefined
83
+
84
+ error?: {
85
+ problemJson?: {
86
+ typeBaseUrl?: string
87
+ }
88
+ }
89
+ }
90
+
91
+ transform?: (
92
+ error: unknown,
93
+ context: { request: Request; code: Code, path: string }
94
+ ) => ProblemError | unknown
95
+ }
96
+
97
+
98
+
99
+ export interface Logger {
100
+ pino: Pino
101
+ log: (
102
+ level: LogLevel,
103
+ request: Request,
104
+ data: Record<string, unknown>,
105
+ store: StoreData
106
+ ) => void
107
+ handleHttpError: (
108
+ request: Request,
109
+ error: ProblemError,
110
+ store: StoreData,
111
+ options: Options
112
+ ) => void
113
+ debug: (
114
+ request: Request,
115
+ message: string,
116
+ context?: Record<string, unknown>
117
+ ) => void
118
+ info: (
119
+ request: Request,
120
+ message: string,
121
+ context?: Record<string, unknown>
122
+ ) => void
123
+ warn: (
124
+ request: Request,
125
+ message: string,
126
+ context?: Record<string, unknown>
127
+ ) => void
128
+ error: (
129
+ request: Request,
130
+ message: string,
131
+ context?: Record<string, unknown>
132
+ ) => void
133
+ }
134
+
135
+ export interface LogixlysiaContext {
136
+ request: Request
137
+ store: LogixlysiaStore
138
+ }