mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 06:00:58 -05:00
Merge pull request #1055 from SISheogorath/upgrade/winston
Upgrade winston / refactor logging
This commit is contained in:
commit
f9aa001ee7
7 changed files with 25 additions and 17 deletions
|
@ -179,6 +179,7 @@ There are some config settings you need to change in the files below.
|
||||||
| `CMD_HOST` | `localhost` | host to listen on |
|
| `CMD_HOST` | `localhost` | host to listen on |
|
||||||
| `CMD_PORT` | `80` | web app port |
|
| `CMD_PORT` | `80` | web app port |
|
||||||
| `CMD_PATH` | `/var/run/codimd.sock` | path to UNIX domain socket to listen on (if specified, `CMD_HOST` and `CMD_PORT` are ignored) |
|
| `CMD_PATH` | `/var/run/codimd.sock` | path to UNIX domain socket to listen on (if specified, `CMD_HOST` and `CMD_PORT` are ignored) |
|
||||||
|
| `CMD_LOGLEVEL` | `info` | Defines what kind of logs are provided to stdout. |
|
||||||
| `CMD_ALLOW_ORIGIN` | `localhost, codimd.org` | domain name whitelist (use comma to separate) |
|
| `CMD_ALLOW_ORIGIN` | `localhost, codimd.org` | domain name whitelist (use comma to separate) |
|
||||||
| `CMD_PROTOCOL_USESSL` | `true` or `false` | set to use SSL protocol for resources path (only applied when domain is set) |
|
| `CMD_PROTOCOL_USESSL` | `true` or `false` | set to use SSL protocol for resources path (only applied when domain is set) |
|
||||||
| `CMD_URL_ADDPORT` | `true` or `false` | set to add port on callback URL (ports `80` or `443` won't be applied) (only applied when domain is set) |
|
| `CMD_URL_ADDPORT` | `true` or `false` | set to add port on callback URL (ports `80` or `443` won't be applied) (only applied when domain is set) |
|
||||||
|
@ -274,6 +275,7 @@ There are some config settings you need to change in the files below.
|
||||||
| `host` | `localhost` | host to listen on |
|
| `host` | `localhost` | host to listen on |
|
||||||
| `port` | `80` | web app port |
|
| `port` | `80` | web app port |
|
||||||
| `path` | `/var/run/codimd.sock` | path to UNIX domain socket to listen on (if specified, `host` and `port` are ignored) |
|
| `path` | `/var/run/codimd.sock` | path to UNIX domain socket to listen on (if specified, `host` and `port` are ignored) |
|
||||||
|
| `loglevel` | `info` | Defines what kind of logs are provided to stdout. |
|
||||||
| `allowOrigin` | `['localhost']` | domain name whitelist |
|
| `allowOrigin` | `['localhost']` | domain name whitelist |
|
||||||
| `useSSL` | `true` or `false` | set to use SSL server (if `true`, will auto turn on `protocolUseSSL`) |
|
| `useSSL` | `true` or `false` | set to use SSL server (if `true`, will auto turn on `protocolUseSSL`) |
|
||||||
| `hsts` | `{"enable": true, "maxAgeSeconds": 31536000, "includeSubdomains": true, "preload": true}` | [HSTS](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security) options to use with HTTPS (default is the example value, max age is a year) |
|
| `hsts` | `{"enable": true, "maxAgeSeconds": 31536000, "includeSubdomains": true, "preload": true}` | [HSTS](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security) options to use with HTTPS (default is the example value, max age is a year) |
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"development": {
|
"development": {
|
||||||
|
"loglevel": "debug",
|
||||||
"hsts": {
|
"hsts": {
|
||||||
"enable": false
|
"enable": false
|
||||||
},
|
},
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
},
|
},
|
||||||
"production": {
|
"production": {
|
||||||
"domain": "localhost",
|
"domain": "localhost",
|
||||||
|
"loglevel": "info"
|
||||||
"hsts": {
|
"hsts": {
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"maxAgeSeconds": "31536000",
|
"maxAgeSeconds": "31536000",
|
||||||
|
|
|
@ -7,6 +7,7 @@ module.exports = {
|
||||||
urlPath: '',
|
urlPath: '',
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
port: 3000,
|
port: 3000,
|
||||||
|
loglevel: 'info',
|
||||||
urlAddPort: false,
|
urlAddPort: false,
|
||||||
allowOrigin: ['localhost'],
|
allowOrigin: ['localhost'],
|
||||||
useSSL: false,
|
useSSL: false,
|
||||||
|
|
|
@ -9,6 +9,7 @@ module.exports = {
|
||||||
host: process.env.CMD_HOST,
|
host: process.env.CMD_HOST,
|
||||||
port: toIntegerConfig(process.env.CMD_PORT),
|
port: toIntegerConfig(process.env.CMD_PORT),
|
||||||
path: process.env.CMD_PATH,
|
path: process.env.CMD_PATH,
|
||||||
|
loglevel: process.env.CMD_LOGLEVEL,
|
||||||
urlAddPort: toBooleanConfig(process.env.CMD_URL_ADDPORT),
|
urlAddPort: toBooleanConfig(process.env.CMD_URL_ADDPORT),
|
||||||
useSSL: toBooleanConfig(process.env.CMD_USESSL),
|
useSSL: toBooleanConfig(process.env.CMD_USESSL),
|
||||||
hsts: {
|
hsts: {
|
||||||
|
|
|
@ -45,6 +45,12 @@ merge(config, require('./hackmdEnvironment'))
|
||||||
merge(config, require('./environment'))
|
merge(config, require('./environment'))
|
||||||
merge(config, require('./dockerSecret'))
|
merge(config, require('./dockerSecret'))
|
||||||
|
|
||||||
|
if (['debug', 'verbose', 'info', 'warn', 'error'].includes(config.loglevel)) {
|
||||||
|
logger.level = config.loglevel
|
||||||
|
} else {
|
||||||
|
logger.error('Selected loglevel %s doesn\'t exist, using default level \'debug\'. Available options: debug, verbose, info, warn, error', config.loglevel)
|
||||||
|
}
|
||||||
|
|
||||||
// load LDAP CA
|
// load LDAP CA
|
||||||
if (config.ldap.tlsca) {
|
if (config.ldap.tlsca) {
|
||||||
let ca = config.ldap.tlsca.split(',')
|
let ca = config.ldap.tlsca.split(',')
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
const winston = require('winston')
|
const {createLogger, format, transports} = require('winston')
|
||||||
|
|
||||||
class Logger extends winston.Logger {
|
module.exports = createLogger({
|
||||||
// Implement stream.writable.write interface
|
|
||||||
write (chunk) {
|
|
||||||
this.info(chunk)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = new Logger({
|
|
||||||
transports: [
|
|
||||||
new winston.transports.Console({
|
|
||||||
level: 'debug',
|
level: 'debug',
|
||||||
handleExceptions: true,
|
format: format.combine(
|
||||||
json: false,
|
format.uncolorize(),
|
||||||
colorize: false,
|
format.timestamp(),
|
||||||
timestamp: true
|
format.align(),
|
||||||
|
format.splat(),
|
||||||
|
format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
|
||||||
|
),
|
||||||
|
transports: [
|
||||||
|
new transports.Console({
|
||||||
|
handleExceptions: true
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
emitErrs: true,
|
|
||||||
exitOnError: false
|
exitOnError: false
|
||||||
})
|
})
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
"velocity-animate": "^1.4.0",
|
"velocity-animate": "^1.4.0",
|
||||||
"visibilityjs": "^1.2.4",
|
"visibilityjs": "^1.2.4",
|
||||||
"viz.js": "^1.7.0",
|
"viz.js": "^1.7.0",
|
||||||
"winston": "^2.3.0",
|
"winston": "^3.1.0",
|
||||||
"ws": "^6.0.0",
|
"ws": "^6.0.0",
|
||||||
"xss": "^1.0.3"
|
"xss": "^1.0.3"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue