Use nanoseconds in server logs (#6880)

This commit is contained in:
William Durand 2018-11-09 21:45:59 +01:00 коммит произвёл GitHub
Родитель dab0639006
Коммит 9cc7038d90
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 33 добавлений и 14 удалений

Просмотреть файл

@ -235,9 +235,10 @@
"moment": "2.22.2",
"mozilla-hybrid-content-telemetry": "1.2.1",
"mozilla-version-comparator": "1.0.2",
"nano-time": "1.0.0",
"normalize.css": "8.0.0",
"pino": "5.8.1",
"pino-mozlog": "1.2.0",
"pino-mozlog": "2.0.0",
"prop-types": "15.6.2",
"qhistory": "1.0.2",
"qs": "6.5.2",

Просмотреть файл

@ -4,6 +4,7 @@ import { AMO_REQUEST_ID_HEADER } from 'core/constants';
let pino = null;
let httpContext = null;
let nanoSeconds = null;
if (process.env.NODE_ENV === 'test') {
// We explicitely require the "browser" (client) version of Pino to write
// logs with `console` and not `stdout` so that Jest can handle the output.
@ -19,16 +20,25 @@ if (process.env.NODE_ENV === 'test') {
pino = require('pino');
}
const pinoLogger = pino({
level: config.get('loggingLevel'),
name: config.get('appName'),
});
if (config.get('enableRequestID')) {
// eslint-disable-next-line global-require
httpContext = require('express-http-context');
}
if (config.get('server')) {
// eslint-disable-next-line global-require
nanoSeconds = require('nano-time');
}
const pinoLogger = pino({
level: config.get('loggingLevel'),
name: config.get('appName'),
// That is how the upstream library implements this... See:
// https://github.com/pinojs/pino/blob/220e3d019fe22167a59cfe26260f6c2b4d0ea22b/lib/time.js#L5
// Note: `true` is the default value for this parameter.
timestamp: nanoSeconds ? () => `,"time":${nanoSeconds()}` : true,
});
export default ['debug', 'error', 'fatal', 'info', 'trace', 'warn'].reduce(
(decoratedLogger, level) => {
return {

Просмотреть файл

@ -2221,6 +2221,11 @@ better-npm-run@0.1.1:
dotenv "^2.0.0"
object-assign "^4.0.1"
big-integer@^1.6.16:
version "1.6.36"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.36.tgz#78631076265d4ae3555c04f85e7d9d2f3a071a36"
integrity sha512-t70bfa7HYEA1D9idDbmuv7YbsbVkQ+Hp+8KFSul4aE5e/i1bjCNIRYJZlA8Q8p0r9T8cF/RVvwUgRA//FydEyg==
big.js@^3.1.3:
version "3.2.0"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e"
@ -6012,10 +6017,6 @@ inquirer@^5.2.0:
strip-ansi "^4.0.0"
through "^2.3.6"
internet-timestamp@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/internet-timestamp/-/internet-timestamp-0.0.1.tgz#16b4a7ada6d1110d4e141fd443756b81b16d1712"
interpret@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"
@ -7892,6 +7893,13 @@ nan@^2.10.0, nan@^2.3.0, nan@^2.6.2, nan@^2.9.2:
version "2.10.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f"
nano-time@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/nano-time/-/nano-time-1.0.0.tgz#b0554f69ad89e22d0907f7a12b0993a5d96137ef"
integrity sha1-sFVPaa2J4i0JB/ehKwmTpdlhN+8=
dependencies:
big-integer "^1.6.16"
nanomatch@^1.2.9:
version "1.2.13"
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@ -8791,11 +8799,11 @@ pino-devtools@^2.1.0:
through2 "^2.0.3"
ws "^6.0.0"
pino-mozlog@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/pino-mozlog/-/pino-mozlog-1.2.0.tgz#79b78751aef3611ba60327c63f3f0c73269179a6"
pino-mozlog@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/pino-mozlog/-/pino-mozlog-2.0.0.tgz#df6377473e126a94841c7afde1526bb30f782d76"
integrity sha512-6CpTEBfYo0yHnZDeTYmFbOP2DRsszJNzqywEVTRkLR1lK03AH1WDXN4ZxdlkRLBgYAMtxqgtCdwkGVrv2IhMHg==
dependencies:
internet-timestamp "^0.0.1"
minimist "^1.2.0"
pino-syslog "^1.2.0"
pump "^3.0.0"