feat(logger): get service name via env var, hide logs on tests
This commit is contained in:
parent
0d0c4c8469
commit
235c7c1ef4
@ -15,6 +15,7 @@ export const logger = createLogger({
|
|||||||
),
|
),
|
||||||
transports: [
|
transports: [
|
||||||
new transports.Console({
|
new transports.Console({
|
||||||
|
silent: import.meta.env.NODE_ENV === 'test',
|
||||||
format: format.combine(
|
format: format.combine(
|
||||||
format.colorize({ all: true }),
|
format.colorize({ all: true }),
|
||||||
format.padLevels(),
|
format.padLevels(),
|
||||||
@ -32,9 +33,10 @@ export const logger = createLogger({
|
|||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
new LokiTransport({
|
new LokiTransport({
|
||||||
|
silent: import.meta.env.NODE_ENV === 'test',
|
||||||
host: 'http://localhost:9100',
|
host: 'http://localhost:9100',
|
||||||
json: true,
|
json: true,
|
||||||
labels: { service: 'api' },
|
labels: { service: import.meta.env.SERVICE_NAME ?? 'unknown' },
|
||||||
format: format.json(),
|
format: format.json(),
|
||||||
replaceTimestamp: true,
|
replaceTimestamp: true,
|
||||||
onConnectionError: (err) => console.error(err),
|
onConnectionError: (err) => console.error(err),
|
||||||
|
Loading…
Reference in New Issue
Block a user