create-graphql-server-logging
Adds logging functions to the GraphQL-Server-Generator: create-graphql-server
;
adds functions:
- getLogFilename
- logger
With getLogFilename it determines the loggers path and filename from your package.json section. The logger function provides a winston logging environment.
Usage
Your server logs now all Graphql requests and nice formatted queries to the log file, which you've defined. This works only with loglevel = debug. It also allows logfile sizes of 5 MB and maximum 5 logfiles.
Installation
yarn add create-graphql-server-logging
In the create-graphql-server project add the following lines to server/index.js, so you are adding the logger to the server's context. Afterwards you can use it for example in your model files with "this.context.log".
...; // <===const log = ; // <=== here... app;
Add in package.json the following section:
"scripts": ..."config": // <=== "logfile": "log/all-logs-readable.log" // <=== "loglevel": "debug" // <=== "maxsize": 5 // <=== "maxfiles": 5 // <===