enhance(logging): ログの情報を増やす (MisskeyIO#351)
This commit is contained in:
@@ -96,7 +96,7 @@ export class FileServerService {
|
||||
|
||||
@bindThis
|
||||
private async errorHandler(request: FastifyRequest<{ Params?: { [x: string]: any }; Querystring?: { [x: string]: any }; }>, reply: FastifyReply, err?: any) {
|
||||
this.logger.error(`${err}`);
|
||||
this.logger.error('file server error', { error: err });
|
||||
|
||||
reply.header('Cache-Control', 'max-age=300');
|
||||
|
||||
|
@@ -371,14 +371,13 @@ export class ApiCallService implements OnApplicationShutdown {
|
||||
this.logger.error(`Internal error occurred in ${ep.name}: ${err.message}`, {
|
||||
ep: ep.name,
|
||||
ps: data,
|
||||
e: {
|
||||
id: errId,
|
||||
error: {
|
||||
message: err.message,
|
||||
code: err.name,
|
||||
stack: err.stack,
|
||||
id: errId,
|
||||
},
|
||||
});
|
||||
console.error(err, errId);
|
||||
throw new ApiError(null, {
|
||||
e: {
|
||||
message: err.message,
|
||||
|
@@ -6,10 +6,12 @@
|
||||
import ms from 'ms';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/const.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import { DriveService } from '@/core/DriveService.js';
|
||||
import { ApiError } from '../../../error.js';
|
||||
|
||||
@@ -73,9 +75,12 @@ export const paramDef = {
|
||||
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||
private logger: Logger;
|
||||
|
||||
constructor(
|
||||
private driveFileEntityService: DriveFileEntityService,
|
||||
private metaService: MetaService,
|
||||
private loggerService: LoggerService,
|
||||
private driveService: DriveService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me, _, file, cleanup, ip, headers) => {
|
||||
@@ -109,9 +114,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
});
|
||||
return await this.driveFileEntityService.pack(driveFile, me, { self: true });
|
||||
} catch (err) {
|
||||
if (err instanceof Error || typeof err === 'string') {
|
||||
console.error(err);
|
||||
}
|
||||
this.logger.error('Failed to create drive file', { error: err });
|
||||
if (err instanceof IdentifiableError) {
|
||||
if (err.id === '282f77bf-5816-4f72-9264-aa14d8261a21') throw new ApiError(meta.errors.inappropriate);
|
||||
if (err.id === 'c6244ed2-a39a-4e1c-bf93-f0fbd7764fa6') throw new ApiError(meta.errors.noFreeSpace);
|
||||
@@ -121,5 +124,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
cleanup!();
|
||||
}
|
||||
});
|
||||
|
||||
this.logger = this.loggerService.getLogger('api:drive:files:create');
|
||||
}
|
||||
}
|
||||
|
@@ -138,8 +138,7 @@ async function discoverClientInformation(logger: Logger, httpRequestService: Htt
|
||||
name: typeof name === 'string' ? name : id,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
logger.error('Error while fetching client information', { err });
|
||||
logger.error('Error while fetching client information', { error: err });
|
||||
if (err instanceof StatusError) {
|
||||
throw new AuthorizationError('Failed to fetch client information', 'invalid_request');
|
||||
} else {
|
||||
|
@@ -783,9 +783,8 @@ export class ClientServerService {
|
||||
path: request.routeOptions.url,
|
||||
params: request.params,
|
||||
query: request.query,
|
||||
code: error.name,
|
||||
stack: error.stack,
|
||||
id: errId,
|
||||
error,
|
||||
});
|
||||
reply.code(500);
|
||||
reply.header('Cache-Control', 'max-age=10, must-revalidate');
|
||||
|
Reference in New Issue
Block a user