koa-req-res-logger




A GraphQL aware request/ response logger for Koa 2.
The logger accepts an option logger which must be a winston compatible logger.
If not provided, winston is used.
The generated log data has the following structure:
interface Request {
method: string;
url: string;
header: object;
graphql?: {
operationName?: string;
query?: string;
variables?: object;
}
}
interface Response {
procTime: number;
status: number;
header: object;
graphql?: {
operationName?: string;
query?: string;
variables?: object;
}
}
GraphQL Logging
The GraphQL request data will be only included in one of the logs.
Logging GraphQL data requires that the body of this request has been read.
If the body has not been read when it reaches the request log, it will be logged in the response.
Usage
see test.js.
Options
logger Winston compatible logger like Restore Logger.
logResBody [false] Whether the response body should be logged or not.
logGraphQL [false] Whether graphql-specific data should be logged or not.
logGraphQLVariables [false] Whether graphql request variables should be logged or not.