1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-03-20 20:55:18 +02:00
This commit is contained in:
Laurent Cozic 2020-12-28 17:26:15 +00:00
parent 0e0de1207f
commit 34a99f738c
3 changed files with 6 additions and 6 deletions

View File

@ -180,7 +180,7 @@ class Logger {
if (level == LogLevel.Warn) fn = 'warn'; if (level == LogLevel.Warn) fn = 'warn';
if (level == LogLevel.Info) fn = 'info'; if (level == LogLevel.Info) fn = 'info';
const consoleObj = target.console ? target.console : console; const consoleObj = target.console ? target.console : console;
let items:any[] = []; let items: any[] = [];
if (target.format) { if (target.format) {
const format = level === LogLevel.Info && target.formatInfo ? target.formatInfo : target.format; const format = level === LogLevel.Info && target.formatInfo ? target.formatInfo : target.format;

View File

@ -71,11 +71,11 @@ app.use(async (ctx: Koa.Context) => {
} }
} catch (error) { } catch (error) {
if (error.httpCode >= 400 && error.httpCode < 500) { if (error.httpCode >= 400 && error.httpCode < 500) {
appLogger().error(error.httpCode + ': ' + `${ctx.request.method} ${ctx.path}` + ' : ' + error.message); appLogger().error(`${error.httpCode}: ` + `${ctx.request.method} ${ctx.path}` + ` : ${error.message}`);
} else { } else {
appLogger().error(error); appLogger().error(error);
} }
ctx.response.status = error.httpCode ? error.httpCode : 500; ctx.response.status = error.httpCode ? error.httpCode : 500;
const responseFormat = routeResponseFormat(match, ctx.path); const responseFormat = routeResponseFormat(match, ctx.path);
@ -111,8 +111,8 @@ async function main() {
const globalLogger = new Logger(); const globalLogger = new Logger();
// globalLogger.addTarget(TargetType.File, { path: `${config().logDir}/app.txt` }); // globalLogger.addTarget(TargetType.File, { path: `${config().logDir}/app.txt` });
globalLogger.addTarget(TargetType.Console, { globalLogger.addTarget(TargetType.Console, {
format: '%(date_time)s: [%(level)s] %(prefix)s: %(message)s', format: '%(date_time)s: [%(level)s] %(prefix)s: %(message)s',
formatInfo: '%(date_time)s: %(prefix)s: %(message)s', formatInfo: '%(date_time)s: %(prefix)s: %(message)s',
}); });
Logger.initializeGlobalLogger(globalLogger); Logger.initializeGlobalLogger(globalLogger);

View File

@ -145,7 +145,7 @@ export function parseSubPath(p: string): SubPath {
return output; return output;
} }
export function routeResponseFormat(match: MatchedRoute, rawPath:string): RouteResponseFormat { export function routeResponseFormat(match: MatchedRoute, rawPath: string): RouteResponseFormat {
if (match && match.route.responseFormat) return match.route.responseFormat; if (match && match.route.responseFormat) return match.route.responseFormat;
let path = rawPath; let path = rawPath;