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