New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flaschenpost

Package Overview
Dependencies
Maintainers
1
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flaschenpost - npm Package Compare versions

Comparing version 0.5.4 to 0.5.5

5

lib/flaschenpost.js

@@ -7,3 +7,4 @@ 'use strict';

findRoot = require('find-root'),
oboe = require('oboe');
oboe = require('oboe'),
traceback = require('traceback-safe');

@@ -54,3 +55,3 @@ var Configuration = require('./Configuration'),

if (!source) {
throw new Error('Source is missing.');
source = traceback()[1].path;
}

@@ -57,0 +58,0 @@

4

lib/Middleware/index.js

@@ -16,6 +16,2 @@ 'use strict';

if (!source) {
throw new Error('Source is missing.');
}
options = {};

@@ -22,0 +18,0 @@ options.objectMode = true;

{
"name": "flaschenpost",
"version": "0.5.4",
"version": "0.5.5",
"description": "flaschenpost is a logger for cloud-based applications.",

@@ -28,2 +28,3 @@ "contributors": [

"oboe": "2.0.2",
"traceback-safe": "0.3.1-1",
"update-notifier": "0.2.2",

@@ -30,0 +31,0 @@ "varname": "1.0.2"

@@ -27,5 +27,11 @@ # flaschenpost

Next, call the `getLogger` function to acquire a logger. You have to provide `__filename` as parameter, as this value will be used to detect the appropriate `package.json` file and extract information about the current module.
Next, call the `getLogger` function to acquire a logger. If you don't provide a parameter flaschenpost identifies the caller automatically.
```javascript
var logger = flaschenpost.getLogger();
```
In rare cases you need to specify the caller manually, e.g. if you wrap flaschenpost in your own logging module. In these cases, provide `__filename` as parameter.
```javascript
var logger = flaschenpost.getLogger(__filename);

@@ -114,6 +120,14 @@ ```

For that, provide the `stream` property when setting up morgan and call the `Middleware` constructor function with the desired log level and the path to the `package.json` file that shall be used for the module information.
For that, provide the `stream` property when setting up morgan and call the `Middleware` constructor function with the desired log level.
```javascript
app.use(morgan('combined', {
stream: new flaschenpost.Middleware('info')
}));
```
Again, in rare cases it may be necessary to provide the file name of the caller on your own.
```javascript
app.use(morgan('combined', {
stream: new flaschenpost.Middleware('info', __filename)

@@ -120,0 +134,0 @@ }));

@@ -51,9 +51,2 @@ 'use strict';

test('throws an error if source is missing.', function (done) {
assert.that(function () {
flaschenpost.getLogger();
}, is.throwing('Source is missing.'));
done();
});
test('throws an error if source is not a valid path.', function (done) {

@@ -137,2 +130,34 @@ assert.that(function () {

test('writes the message to a letter even when no filename was specified.', function (done) {
var logger = flaschenpost.getLogger();
letter.once('data', function (paragraph) {
assert.that(paragraph, is.ofType('object'));
assert.that(paragraph.pid, is.equalTo(process.pid));
assert.that(paragraph.id, is.ofType('number'));
assert.that(paragraph.timestamp, is.not.undefined());
assert.that(paragraph.level, is.equalTo('info'));
assert.that(paragraph.message, is.equalTo('App bar started.'));
assert.that(paragraph.module, is.equalTo({
name: 'foo',
version: '0.0.1'
}));
assert.that(paragraph.source, is.equalTo(__filename));
assert.that(paragraph.metadata, is.equalTo({
foo: 'bar',
metadata: {
bar: 'baz'
}
}));
done();
});
logger.info('App {{foo}} started.', {
foo: 'bar',
metadata: {
bar: 'baz'
}
});
});
test('does not write a message if the log level is disabled.', function (done) {

@@ -139,0 +164,0 @@ var logger = flaschenpost.getLogger(__filename);

@@ -9,3 +9,4 @@ 'use strict';

letter = require('../../lib/letter'),
Middleware = require('../../lib/Middleware');
Middleware = require('../../lib/Middleware'),
packageJson = require('../../package.json');

@@ -33,11 +34,2 @@ var Writable = stream.Writable;

test('throws an error if source is missing.', function (done) {
assert.that(function () {
/*eslint-disable no-new*/
new Middleware('info');
/*eslint-enable no-new*/
}, is.throwing('Source is missing.'));
done();
});
test('throws an error if the specified level does not exist.', function (done) {

@@ -72,2 +64,18 @@ assert.that(function () {

});
test('writes messages using the specified log level even if no filename was specified.', function (done) {
var middleware = new Middleware('info');
letter.once('data', function (data) {
assert.that(data.level, is.equalTo('info'));
assert.that(data.message, is.equalTo('foobar'));
assert.that(data.module, is.equalTo({
name: packageJson.name,
version: packageJson.version
}));
done();
});
middleware.write('foobar');
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc