feat: add logs to domain services#301
feat: add logs to domain services#3017eliassen wants to merge 7 commits intochore/logs-and-optimizationfrom
Conversation
Coverage Report
File Coverage |
| * Implementations are provided by the infrastructure layer | ||
| */ | ||
|
|
||
| export interface DomainLogger { |
There was a problem hiding this comment.
domain server shared space was designed as a place, where you declare methods of actual domain, that could be used by other domains
i think that the DomainLogger should be moved to infrastructure/logging/, since it does not really belongs here
(check readme inside of the domain/service/shared)
| const cachedLogger = loggerCache.get(moduleName); | ||
|
|
||
| if (cachedLogger) { | ||
| return cachedLogger; | ||
| } | ||
|
|
There was a problem hiding this comment.
seems like a part of different PR, should this branch be rebased?
There was a problem hiding this comment.
I changed the base branch to chore/logs-and-optimization
| if (session.refreshTokenExpiresAt.getTime() < Date.now()) { | ||
| await this.userSessionRepository.removeUserSessionByRefreshToken(token); | ||
|
|
||
| this.logger.warn('Refresh token expired'); |
There was a problem hiding this comment.
lets print last 4 chars of the token in all logs about tokens
| */ | ||
| export default async function authRequired(context: PolicyContext): Promise<void> { | ||
| const { request, reply } = context; | ||
| const logger = getRequestLogger('policies'); |
There was a problem hiding this comment.
can we add a policy name as a prefix of its logs?
| const logger = getRequestLogger('database'); | ||
|
|
||
| logger.info( | ||
| { durationMs: timing }, | ||
| message |
|
Thanks for adding a description — the PR is now marked as Ready for Review. |
Add request-scoped business event logging to domain services.
domainmodule nameDomainLogerinterface to keep domain layer decoupled from infrastructure logging implementation. That preserve clean architecture.PinoDomainLoggerAdapterthat implementsDomainLoggerDomainErrorhandler to include reqId anddomainmodule name in logs