mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
reduce log spam from ApiCallService
This commit is contained in:
parent
22653efdc4
commit
d3d201d0cf
1 changed files with 10 additions and 8 deletions
|
@ -27,6 +27,7 @@ import { AuthenticateService, AuthenticationError } from './AuthenticateService.
|
||||||
import type { FastifyRequest, FastifyReply } from 'fastify';
|
import type { FastifyRequest, FastifyReply } from 'fastify';
|
||||||
import type { OnApplicationShutdown } from '@nestjs/common';
|
import type { OnApplicationShutdown } from '@nestjs/common';
|
||||||
import type { IEndpointMeta, IEndpoint } from './endpoints.js';
|
import type { IEndpointMeta, IEndpoint } from './endpoints.js';
|
||||||
|
import { renderFullError } from '@/misc/render-full-error.js';
|
||||||
|
|
||||||
const accessDenied = {
|
const accessDenied = {
|
||||||
message: 'Access denied.',
|
message: 'Access denied.',
|
||||||
|
@ -101,15 +102,16 @@ export class ApiCallService implements OnApplicationShutdown {
|
||||||
throw err;
|
throw err;
|
||||||
} else {
|
} else {
|
||||||
const errId = randomUUID();
|
const errId = randomUUID();
|
||||||
this.logger.error(`Internal error occurred in ${ep.name}: ${renderInlineError(err)}`, {
|
const fullError = renderFullError(err);
|
||||||
ep: ep.name,
|
const message = typeof(fullError) === 'string'
|
||||||
|
? `Internal error id=${errId} occurred in ${ep.name}: ${fullError}`
|
||||||
|
: `Internal error id=${errId} occurred in ${ep.name}:`;
|
||||||
|
const data = typeof(fullError) === 'object'
|
||||||
|
? { e: fullError }
|
||||||
|
: {};
|
||||||
|
this.logger.error(message, {
|
||||||
user: userId ?? '<unauthenticated>',
|
user: userId ?? '<unauthenticated>',
|
||||||
e: {
|
...data,
|
||||||
message: err.message,
|
|
||||||
code: err.name,
|
|
||||||
stack: err.stack,
|
|
||||||
id: errId,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.config.sentryForBackend) {
|
if (this.config.sentryForBackend) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue