@sealsystems/log
Advanced tools
Comparing version 2.4.3 to 2.5.0
'use strict'; | ||
const { flaschenpost } = require('flaschenpost'); | ||
const { loggerFactory } = require('./loggerFactory'); | ||
const logAndTerminate = function (err, promise) { | ||
if (promise) { | ||
flaschenpost.getLogger().fatal('Unhandled rejection occurred. Terminate process.', { err, promise }); | ||
loggerFactory.getLogger().fatal('Unhandled rejection occurred. Terminate process.', { err, promise }); | ||
} else { | ||
flaschenpost.getLogger().fatal('Uncaught exception occurred. Terminate process.', { err }); | ||
loggerFactory.getLogger().fatal('Uncaught exception occurred. Terminate process.', { err }); | ||
} | ||
@@ -11,0 +11,0 @@ |
'use strict'; | ||
// Parse environment variable LOG_LEVEL if set, overwrites LOG_LEVELS | ||
require('./parseLogLevelEnv')(); | ||
const { loggerFactory } = require('./loggerFactory'); | ||
const { flaschenpost } = require('flaschenpost'); | ||
const logAndTerminate = require('./logAndTerminate'); | ||
const getMiddleware = require('./getMiddleware'); | ||
@@ -18,22 +14,2 @@ // 1. Do not log multiple times if different versions of this module are required in the project | ||
const defaultConfig = flaschenpost.getConfiguration(); | ||
flaschenpost.configure( | ||
defaultConfig.withFormatter((logEntry) => { | ||
logEntry.isoTimestamp = new Date(logEntry.timestamp).toISOString(); | ||
if (logEntry.metadata) { | ||
// try to avoid type mismatches in elasticsearch (pls-1626) | ||
if (typeof logEntry.metadata !== 'object') { | ||
logEntry.metadata = { value: logEntry.metadata.toString() }; | ||
} | ||
// Temporary: If incoming metadata is not of type object, transform it. | ||
// This is neccessary to fit the type definitions in ELK | ||
else if (logEntry.metadata.err && typeof logEntry.metadata.err !== 'object') { | ||
logEntry.metadata.err = { message: logEntry.metadata.err.toString() }; | ||
} | ||
} | ||
return defaultConfig.formatter(logEntry); | ||
}) | ||
); | ||
flaschenpost.Middleware = getMiddleware(flaschenpost); | ||
module.exports = flaschenpost; | ||
module.exports = loggerFactory; |
{ | ||
"name": "@sealsystems/log", | ||
"version": "2.4.3", | ||
"version": "2.5.0", | ||
"description": "Logger for all Node.js modules by SEAL Systems", | ||
@@ -28,11 +28,16 @@ "author": { | ||
"dependencies": { | ||
"flaschenpost": "5.0.49", | ||
"stack-trace": "0.0.10" | ||
"app-root-path": "3.1.0", | ||
"chalk": "4.1.2", | ||
"find-root": "1.1.0", | ||
"lodash": "4.17.21", | ||
"serialize-error": "8.1.0", | ||
"stack-trace": "0.0.10", | ||
"stringify-object": "3.3.0" | ||
}, | ||
"devDependencies": { | ||
"@sealsystems/eslint-config-es": "3.7.8", | ||
"@sealsystems/eslint-config-es": "3.7.10", | ||
"@sealsystems/mocha": "4.2.3", | ||
"nodeenv": "3.0.71", | ||
"nodeenv": "3.0.75", | ||
"proxyquire": "2.1.3", | ||
"sinon": "12.0.1" | ||
"sinon": "19.0.2" | ||
}, | ||
@@ -39,0 +44,0 @@ "release": { |
@@ -10,3 +10,3 @@ # @sealsystems/log | ||
```bash | ||
$ npm install @sealsystems/log | ||
npm install @sealsystems/log | ||
``` | ||
@@ -62,34 +62,7 @@ | ||
## Environment Variables | ||
## Environment Variable LOG_LEVEL | ||
_Please note that when using mocha, all log-levels are always activated. See [`flaschenpost`](https://www.npmjs.com/package/flaschenpost#setting-a-custom-host)._ | ||
### LOG_LEVELS | ||
A list of log levels to print out. Possible levels are: | ||
- `debug` | ||
- `info` | ||
- `warn` | ||
- `error` | ||
- `fatal` | ||
You have to provide a comma seperated list of the log levels you are interessted in: | ||
``` | ||
LOG_LEVELS=info,warn,error,fatal | ||
``` | ||
The list given above is the default setting, if no environment variable is set. | ||
You can enable all logging levels with the shortcut | ||
``` | ||
LOG_LEVELS=* | ||
``` | ||
### LOG_LEVEL | ||
A single minimum log level which includes all higher levels. | ||
``` | ||
```bash | ||
LOG_LEVEL=warn | ||
@@ -99,3 +72,1 @@ ``` | ||
The setting above includes log levels `warn`, `error` and `fatal`. | ||
The environment variable `LOG_LEVEL` has precedence over `LOG_LEVELS`. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
13063
14
287
7
70
1
1
+ Addedapp-root-path@3.1.0
+ Addedchalk@4.1.2
+ Addedfind-root@1.1.0
+ Addedlodash@4.17.21
+ Addedserialize-error@8.1.0
+ Addedstringify-object@3.3.0
+ Addedapp-root-path@3.1.0(transitive)
- Removedflaschenpost@5.0.49
- Removed@types/app-root-path@1.2.4(transitive)
- Removed@types/body-parser@1.19.5(transitive)
- Removed@types/connect@3.4.38(transitive)
- Removed@types/express@4.17.13(transitive)
- Removed@types/express-serve-static-core@4.19.6(transitive)
- Removed@types/find-root@1.1.2(transitive)
- Removed@types/http-errors@2.0.4(transitive)
- Removed@types/lodash@4.14.172(transitive)
- Removed@types/mime@1.3.5(transitive)
- Removed@types/node@16.6.1(transitive)
- Removed@types/on-finished@2.3.1(transitive)
- Removed@types/qs@6.9.18(transitive)
- Removed@types/range-parser@1.2.7(transitive)
- Removed@types/send@0.17.4(transitive)
- Removed@types/serve-static@1.15.7(transitive)
- Removed@types/stack-trace@0.0.29(transitive)
- Removed@types/stringify-object@3.3.1(transitive)
- Removedapp-root-path@3.0.0(transitive)
- Removeddate-fns@2.23.0(transitive)
- Removedee-first@1.1.1(transitive)
- Removedflaschenpost@5.0.49(transitive)
- Removedon-finished@2.3.0(transitive)
- Removedprocessenv@3.0.9(transitive)