ligo/tools/webide/packages/server/src/logger.ts
Jev Björsell c119c44c13
Import webide into main ligo monorepo
When this is merged https://gitlab.com/ligolang/ligo-web-ide/ will be
marked as deprecated.

This MR does not hook up the webide build to the main CI. The CI
integration will come in a subsequent MR for the sake of making review
easier.
2020-02-06 19:04:18 -08:00

25 lines
795 B
TypeScript

import { createLogger, format, transports } from 'winston';
const { combine, timestamp, simple } = format;
import expressWinston from 'express-winston';
interface Logger {
debug: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}
const config = {
format: combine(timestamp(), simple()),
transports: [new transports.Console()]
};
export const logger: Logger = createLogger(config);
export const loggerMiddleware = expressWinston.logger({
...config,
msg: 'HTTP {{req.method}} {{req.url}}',
requestWhitelist: [...expressWinston.requestWhitelist, 'body'],
responseWhitelist: [...expressWinston.responseWhitelist, 'body']
});
export const errorLoggerMiddleware = expressWinston.errorLogger(config);