♻️Removed console.log from backend node + error serializer
This commit is contained in:
committed by
Anton Shepilov
parent
01744274eb
commit
da9736e23b
@@ -12,6 +12,12 @@ export const logger = pino({
|
||||
mixin() {
|
||||
return executionStorage.getStore() ? executionStorage.getStore() : {};
|
||||
},
|
||||
formatters: {
|
||||
level(label: string) {
|
||||
return { level: label.toUpperCase() };
|
||||
},
|
||||
},
|
||||
serializers: pino.stdSerializers,
|
||||
});
|
||||
|
||||
export const getLogger = (name?: string): TdriveLogger =>
|
||||
|
||||
@@ -28,7 +28,7 @@ export async function buildDependenciesTree(
|
||||
`The component dependency ${dependencyName} has not been found for component ${name}`,
|
||||
);
|
||||
} else {
|
||||
console.warn(
|
||||
logger.warn(
|
||||
`(warning) The component dependency ${dependencyName} has not been found for component ${name} it will be imported asynchronously`,
|
||||
);
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ export default class MongoSearch extends SearchAdapter implements SearchAdapterI
|
||||
const { query, sort, project } = buildSearchQuery<EntityType>(entityType, filters, options);
|
||||
|
||||
logger.info(`Search query: ${JSON.stringify(query)}`);
|
||||
console.log(query);
|
||||
logger.info(query);
|
||||
|
||||
const sortMapped: any = sort
|
||||
? Object.fromEntries(
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
import { buildSelectQuery } from "../../../database/services/orm/connectors/mongodb/query-builder";
|
||||
import { EntityTarget, FindFilter, FindOptions, getEntityDefinition } from "../../api";
|
||||
import { asciiFold } from "../utils";
|
||||
import { logger } from "../../../../framework";
|
||||
|
||||
export function buildSearchQuery<Entity>(
|
||||
entityType: EntityTarget<Entity>,
|
||||
@@ -15,7 +16,7 @@ export function buildSearchQuery<Entity>(
|
||||
try {
|
||||
query = buildSelectQuery(entityType, filters, options);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
logger.info(e);
|
||||
}
|
||||
let sort: any = {};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Analytics, { IdentifyParams, TrackParams } from "@segment/analytics-node";
|
||||
import { Analytics as AnalyticsAbtract } from "./types";
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
import { logger } from "../../../framework/logger";
|
||||
|
||||
export default class Segment implements AnalyticsAbtract {
|
||||
protected version = "5.0.0"; //Segment analytics lib version
|
||||
@@ -33,7 +34,7 @@ export default class Segment implements AnalyticsAbtract {
|
||||
try {
|
||||
this.analytics.identify(message as IdentifyParams, callback);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
logger.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ export default class Segment implements AnalyticsAbtract {
|
||||
try {
|
||||
this.analytics.track(message as TrackParams, callback);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
logger.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { FastifyInstance } from "fastify";
|
||||
import { logger } from "../../framework/logger";
|
||||
|
||||
function serverErrorHandler(server: FastifyInstance): void {
|
||||
server.setErrorHandler(async (err, request, reply) => {
|
||||
console.error(`Got ${reply.statusCode} error on request ${request.id} : `, err);
|
||||
logger.error(`Got ${reply.statusCode} error on request ${request.id} : `, err);
|
||||
server.log.debug(`Got ${reply.statusCode} error on request ${request.id} : ${err.toString()}`);
|
||||
await reply.send(
|
||||
reply.statusCode == 500
|
||||
|
||||
Reference in New Issue
Block a user