flaschenpost
Advanced tools
Comparing version 4.3.37 to 5.0.0
import { Configuration } from './Configuration'; | ||
import { Logger } from './Logger'; | ||
import { MorganPlugin } from './MorganPlugin'; | ||
import { PackageJson } from './PackageJson'; | ||
import { asHumanReadable, asJson } from './formatters'; | ||
declare class Flaschenpost { | ||
@@ -14,2 +12,2 @@ protected configuration: Configuration; | ||
declare const flaschenpost: Flaschenpost; | ||
export { flaschenpost, Configuration, Flaschenpost, asHumanReadable, asJson, Logger, MorganPlugin }; | ||
export { flaschenpost, Flaschenpost }; |
@@ -6,6 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MorganPlugin = exports.Logger = exports.asJson = exports.asHumanReadable = exports.Flaschenpost = exports.Configuration = exports.flaschenpost = void 0; | ||
exports.Flaschenpost = exports.flaschenpost = void 0; | ||
const lodash_1 = require("lodash"); | ||
const Configuration_1 = require("./Configuration"); | ||
Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return Configuration_1.Configuration; } }); | ||
const find_root_1 = __importDefault(require("find-root")); | ||
@@ -16,5 +15,2 @@ const fs_1 = __importDefault(require("fs")); | ||
const Logger_1 = require("./Logger"); | ||
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return Logger_1.Logger; } }); | ||
const MorganPlugin_1 = require("./MorganPlugin"); | ||
Object.defineProperty(exports, "MorganPlugin", { enumerable: true, get: function () { return MorganPlugin_1.MorganPlugin; } }); | ||
const os_1 = __importDefault(require("os")); | ||
@@ -25,4 +21,2 @@ const processenv_1 = require("processenv"); | ||
const formatters_1 = require("./formatters"); | ||
Object.defineProperty(exports, "asHumanReadable", { enumerable: true, get: function () { return formatters_1.asHumanReadable; } }); | ||
Object.defineProperty(exports, "asJson", { enumerable: true, get: function () { return formatters_1.asJson; } }); | ||
class Flaschenpost { | ||
@@ -29,0 +23,0 @@ constructor() { |
@@ -0,1 +1,13 @@ | ||
# [5.0.0](https://github.com/thenativeweb/flaschenpost/compare/4.3.37...5.0.0) (2021-02-10) | ||
### Features | ||
* Replace Morgan plugin by new middleware. ([#569](https://github.com/thenativeweb/flaschenpost/issues/569)) ([16802a3](https://github.com/thenativeweb/flaschenpost/commit/16802a33b9ba8239ae49bfa62737d24852334615)) | ||
### BREAKING CHANGES | ||
* The morgan plugin was replaced by a new middleware that was written from scratch that now works without morgan. | ||
## [4.3.37](https://github.com/thenativeweb/flaschenpost/compare/4.3.36...4.3.37) (2021-02-08) | ||
@@ -2,0 +14,0 @@ |
@@ -8,3 +8,2 @@ import { cloneDeep } from 'lodash'; | ||
import { Logger } from './Logger'; | ||
import { MorganPlugin } from './MorganPlugin'; | ||
import os from 'os'; | ||
@@ -106,2 +105,2 @@ import { PackageJson } from './PackageJson'; | ||
export { flaschenpost, Configuration, Flaschenpost, asHumanReadable, asJson, Logger, MorganPlugin }; | ||
export { flaschenpost, Flaschenpost }; |
The MIT License (MIT) | ||
Copyright (c) 2013-2020 the native web. | ||
Copyright (c) 2013-2021 the native web. | ||
@@ -4,0 +4,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
{ | ||
"name": "flaschenpost", | ||
"version": "4.3.37", | ||
"version": "5.0.0", | ||
"description": "flaschenpost is a logger for cloud-based applications.", | ||
@@ -39,9 +39,11 @@ "contributors": [ | ||
], | ||
"main": "build/lib/flaschenpost.js", | ||
"types": "build/lib/flaschenpost.d.ts", | ||
"main": "build/lib/index.js", | ||
"types": "build/lib/index.d.ts", | ||
"dependencies": { | ||
"@types/app-root-path": "1.2.4", | ||
"@types/express": "4.17.11", | ||
"@types/find-root": "1.1.2", | ||
"@types/lodash": "4.14.168", | ||
"@types/node": "14.14.25", | ||
"@types/on-finished": "2.3.1", | ||
"@types/stack-trace": "0.0.29", | ||
@@ -54,2 +56,3 @@ "@types/stringify-object": "3.3.0", | ||
"lodash": "4.17.20", | ||
"on-finished": "2.3.0", | ||
"processenv": "3.0.3", | ||
@@ -62,10 +65,12 @@ "serialize-error": "8.0.1", | ||
"@types/common-tags": "1.8.0", | ||
"@types/express": "4.17.11", | ||
"@types/supertest": "2.0.10", | ||
"assertthat": "5.2.5", | ||
"common-tags": "1.8.0", | ||
"nodeenv": "3.0.39", | ||
"record-stdstreams": "3.0.38", | ||
"roboter": "11.6.6", | ||
"semantic-release-configuration": "1.0.32", | ||
"strip-ansi": "6.0.0" | ||
"express": "4.17.1", | ||
"nodeenv": "3.0.40", | ||
"record-stdstreams": "3.0.39", | ||
"roboter": "11.6.13", | ||
"semantic-release-configuration": "1.0.33", | ||
"strip-ansi": "6.0.0", | ||
"supertest": "6.1.3" | ||
}, | ||
@@ -72,0 +77,0 @@ "repository": { |
@@ -119,8 +119,8 @@ # flaschenpost | ||
### Using the morgan plugin | ||
### Using the flaschenpost middleware | ||
flaschenpost can be used as a plugin for the [morgan](https://www.npmjs.com/package/morgan) logger, e.g. to use flaschenpost in combination with Express. For this, first load flaschenpost's morgan plugin: | ||
flaschenpost can be used as a middleware for Express. For this, first load flaschenpost's `getMiddleware` function: | ||
```javascript | ||
const { MorganPlugin } = require('flaschenpost'); | ||
const { getMiddleware } = require('flaschenpost'); | ||
``` | ||
@@ -131,15 +131,23 @@ | ||
```typescript | ||
import { MorganPlugin } from 'flaschenpost'; | ||
import { getMiddleware } from 'flaschenpost'; | ||
``` | ||
Create an instance of the `MorganPlugin` class and specify the log level you would like to use. Then hand over this instance to morgan by using its `stream` property: | ||
Create an instance of the middleware by calling `getMiddleware` and register it via the usual way in your Express application: | ||
```javascript | ||
const morganPlugin = new MorganPlugin('info'); | ||
app.use(getMiddleware()); | ||
``` | ||
app.use(morgan('combined', { stream: morganPlugin })); | ||
Sometimes you may want to log when the request is received, not when the response was sent, e.g. for long-running connections. For these cases, provide the `logOn` option and set it to `request`: | ||
```javascript | ||
app.use(getMiddleware({ logOn: 'request' })); | ||
``` | ||
If you want to override the log source, you can provide the desired file path as second parameter to the constructor. See [faking log sources](#faking-log-sources) for details. | ||
By default, the middleware uses `info` as log level. To change this, provide the `logLevel` option and set it to the desired value: | ||
```javascript | ||
app.use(getMiddleware({ logLevel: 'warn' })); | ||
``` | ||
### Configuring flaschenpost programmatically | ||
@@ -146,0 +154,0 @@ |
80566
67
1059
260
18
11
+ Added@types/express@4.17.11
+ Added@types/on-finished@2.3.1
+ Addedon-finished@2.3.0
+ Added@types/body-parser@1.19.5(transitive)
+ Added@types/connect@3.4.38(transitive)
+ Added@types/express@4.17.11(transitive)
+ Added@types/express-serve-static-core@4.19.6(transitive)
+ Added@types/http-errors@2.0.4(transitive)
+ Added@types/mime@1.3.5(transitive)
+ Added@types/on-finished@2.3.1(transitive)
+ Added@types/qs@6.9.18(transitive)
+ Added@types/range-parser@1.2.7(transitive)
+ Added@types/send@0.17.4(transitive)
+ Added@types/serve-static@1.15.7(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedon-finished@2.3.0(transitive)