fix: logger meta information
This commit is contained in:
parent
d35391288d
commit
a2b1323568
13 changed files with 29 additions and 21 deletions
|
@ -84,6 +84,7 @@ export class ContainerConfigLoader {
|
|||
level: env.get('LOG_LEVEL', true) || 'info',
|
||||
format: winston.format.combine(...winstonFormatters),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||
defaultMeta: { service: 'analytics' },
|
||||
})
|
||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||
|
||||
|
|
|
@ -43,11 +43,10 @@ export class GRPCSyncingServerServiceProxy {
|
|||
}
|
||||
|
||||
if (error.code === Status.INTERNAL) {
|
||||
this.logger.error(
|
||||
`[GRPCSyncingServerServiceProxy][${response.locals.user.uuid}] Internal gRPC error: ${
|
||||
error.message
|
||||
}. Payload: ${JSON.stringify(payload)}`,
|
||||
)
|
||||
this.logger.error(`Internal gRPC error: ${error.message}. Payload: ${JSON.stringify(payload)}`, {
|
||||
codeTag: 'GRPCSyncingServerServiceProxy',
|
||||
userId: response.locals.user.uuid,
|
||||
})
|
||||
}
|
||||
|
||||
return reject(error)
|
||||
|
@ -60,11 +59,10 @@ export class GRPCSyncingServerServiceProxy {
|
|||
'code' in (error as Record<string, unknown>) &&
|
||||
(error as Record<string, unknown>).code === Status.INTERNAL
|
||||
) {
|
||||
this.logger.error(
|
||||
`[GRPCSyncingServerServiceProxy][${response.locals.user.uuid}] Internal gRPC error: ${JSON.stringify(
|
||||
error,
|
||||
)}. Payload: ${JSON.stringify(payload)}`,
|
||||
)
|
||||
this.logger.error(`Internal gRPC error: ${JSON.stringify(error)}. Payload: ${JSON.stringify(payload)}`, {
|
||||
codeTag: 'GRPCSyncingServerServiceProxy.catch',
|
||||
userId: response.locals.user.uuid,
|
||||
})
|
||||
}
|
||||
|
||||
reject(error)
|
||||
|
|
|
@ -310,7 +310,7 @@ export class ContainerConfigLoader {
|
|||
level: env.get('LOG_LEVEL', true) || 'info',
|
||||
format: winston.format.combine(...winstonFormatters),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||
defaultMeta: { service: 'auth' },
|
||||
defaultMeta: { service: `auth:${this.mode}` },
|
||||
})
|
||||
}
|
||||
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger)
|
||||
|
|
|
@ -19,7 +19,7 @@ import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
|||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
const container = new ContainerConfigLoader('server')
|
||||
void container.load().then((container) => {
|
||||
const env: Env = new Env()
|
||||
env.load()
|
||||
|
|
|
@ -9,7 +9,7 @@ import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
|
|||
import * as dayjs from 'dayjs'
|
||||
import * as utc from 'dayjs/plugin/utc'
|
||||
|
||||
const container = new ContainerConfigLoader()
|
||||
const container = new ContainerConfigLoader('worker')
|
||||
void container.load().then((container) => {
|
||||
dayjs.extend(utc)
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ import { MoveFile } from '../Domain/UseCase/MoveFile/MoveFile'
|
|||
import { SharedVaultValetTokenAuthMiddleware } from '../Infra/InversifyExpress/Middleware/SharedVaultValetTokenAuthMiddleware'
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
constructor(private mode: 'server' | 'worker' = 'server') {}
|
||||
|
||||
async load(configuration?: {
|
||||
directCallDomainEventPublisher?: DirectCallDomainEventPublisher
|
||||
logger?: Transform
|
||||
|
@ -316,7 +318,7 @@ export class ContainerConfigLoader {
|
|||
level: env.get('LOG_LEVEL', true) || 'info',
|
||||
format: winston.format.combine(winston.format.splat(), winston.format.json()),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||
defaultMeta: { service: 'files' },
|
||||
defaultMeta: { service: `files:${this.mode}` },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ export class ContainerConfigLoader {
|
|||
level: env.get('LOG_LEVEL', true) || 'info',
|
||||
format: winston.format.combine(...winstonFormatters),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||
defaultMeta: { service: 'revisions' },
|
||||
defaultMeta: { service: `revisions:${this.mode}` },
|
||||
})
|
||||
}
|
||||
container.bind<winston.Logger>(TYPES.Revisions_Logger).toConstantValue(logger)
|
||||
|
|
|
@ -62,6 +62,7 @@ export class ContainerConfigLoader {
|
|||
level: env.get('LOG_LEVEL', true) || 'info',
|
||||
format: winston.format.combine(...winstonFormatters),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||
defaultMeta: { service: 'scheduler' },
|
||||
})
|
||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ export class ContainerConfigLoader {
|
|||
level: env.get('LOG_LEVEL', true) || 'info',
|
||||
format: winston.format.combine(...winstonFormatters),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||
defaultMeta: { service: 'syncing-server' },
|
||||
defaultMeta: { service: `syncing-server:${this.mode}` },
|
||||
})
|
||||
}
|
||||
container.bind<winston.Logger>(TYPES.Sync_Logger).toConstantValue(logger)
|
||||
|
|
|
@ -49,6 +49,7 @@ export class ContainerConfigLoader {
|
|||
level: env.get('LOG_LEVEL', true) || 'info',
|
||||
format: winston.format.combine(...winstonFormatters),
|
||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||
defaultMeta: { service: `websockets:${this.mode}` },
|
||||
})
|
||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||
|
||||
|
|
|
@ -16,7 +16,9 @@ export class WebSocketMessageRequestedEventHandler implements DomainEventHandler
|
|||
})
|
||||
|
||||
if (result.isFailed()) {
|
||||
this.logger.error(`Could not send message to user ${event.payload.userUuid}. Error: ${result.getError()}`)
|
||||
this.logger.error(`Could not send message to user. Error: ${result.getError()}`, {
|
||||
userId: event.payload.userUuid,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,9 +48,10 @@ export class AddWebSocketsConnection implements UseCaseInterface<void> {
|
|||
|
||||
return Result.ok()
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
`Error persisting connection ${dto.connectionId} for user ${dto.userUuid}: ${(error as Error).message}`,
|
||||
)
|
||||
this.logger.error(`Error persisting connection for user: ${(error as Error).message}`, {
|
||||
userId: dto.userUuid,
|
||||
connectionId: dto.connectionId,
|
||||
})
|
||||
|
||||
return Result.fail((error as Error).message)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,9 @@ export class RemoveWebSocketsConnection implements UseCaseInterface<void> {
|
|||
|
||||
return Result.ok()
|
||||
} catch (error) {
|
||||
this.logger.error(`Error removing connection ${dto.connectionId}: ${(error as Error).message}`)
|
||||
this.logger.error(`Error removing connection: ${(error as Error).message}`, {
|
||||
connectionId: dto.connectionId,
|
||||
})
|
||||
|
||||
return Result.fail((error as Error).message)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue