Socket
Socket
Sign inDemoInstall

logfmt

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logfmt - npm Package Compare versions

Comparing version 0.9.1 to 0.9.2

2

examples/express_pipe_to_stdout.js

@@ -13,3 +13,3 @@ var app = require('express')();

req.body.pipe(through(function(line){
console.dir(line);
console.log(JSON.stringify(line));
}))

@@ -16,0 +16,0 @@

@@ -51,3 +51,2 @@ var split = require('split');

if (req._body) return next();
console.log(req.get('content-type'), mime);
var is_mime = req.get('content-type') === mime;

@@ -54,0 +53,0 @@ if (!is_mime) return next();

{
"name": "logfmt",
"version": "0.9.1",
"version": "0.9.2",
"description": "Key-Value log line parser",

@@ -5,0 +5,0 @@ "main": "logfmt.js",

@@ -5,5 +5,6 @@ # node-logfmt

This library is for both logging object to logfmt format and converting
lines in logfmt format to objects. It provides a parser, a simple log
method, and both streaming and non-streaming body parsers for express.
This library is for both converting lines in logfmt format to objects and
for logging objects to a stream in logfmt format.
It provides a logfmt parser, a logging facility,
and both streaming and non-streaming body parsers for express.

@@ -23,5 +24,16 @@ You should use this library if you're trying to write structured logs or

## parser
### `logfmt.parse(string)`
```javascript
var logfmt = require('logfmt');
logfmt.parse("foo=bar a=14 baz=\"hello kitty\" cool%story=bro f %^asdf code=H12")
//=>{ "foo": "bar", "a": 14, "baz": "hello kitty", "cool%story": "bro", "f": true, "%^asdf": true, "code" : "H12" }
```
## logging
### `logfmt.log()`
### `logfmt.log(object, [stream])`

@@ -54,23 +66,12 @@ Defaults to logging to `process.stdout`

## express middleware
## parser
### Streaming
### `logfmt.parse()`
#### `logfmt.bodyParserStream([opts])`
```javascript
var logfmt = require('logfmt');
Valid Options:
logfmt.parse("foo=bar a=14 baz=\"hello kitty\" cool%story=bro f %^asdf code=H12")
//=>{ "foo": "bar", "a": 14, "baz": "hello kitty", "cool%story": "bro", "f": true, "%^asdf": true, "code" : "H12" }
```
- `contentType`: defaults to `application/logplex-1`
### express middleware
#### Streaming
##### `logfmt.bodyParserStream(opts)`
Valid Options:
contentType: defaults to 'application/logplex-1'
If you use the `logfmt.bodyParserStream()` for a body parser,

@@ -123,9 +124,10 @@ you will have a `req.body` that is a readable stream.

#### Non-Streaming
### Non-Streaming
##### `logfmt.bodyParser(opts)`
#### `logfmt.bodyParser([opts])`
Valid Options:
contentType: defaults to 'application/logplex-1'
Valid Options:
- `contentType`: defaults to `application/logplex-1`
If you use the `logfmt.bodyParser()` for a body parser,

@@ -160,18 +162,20 @@ you will have a `req.body` that is an array of objects.

### command line
## command line
### logfmt
accepts lines on STDIN and converts them to json
echo "foo=bar a=14 baz=\"hello kitty\" cool%story=bro f %^asdf" | logfmt
> echo "foo=bar a=14 baz=\"hello kitty\" cool%story=bro f %^asdf" | logfmt
{ "foo": "bar", "a": 14, "baz": "hello kitty", "cool%story": "bro", "f": true, "%^asdf": true }
#### reverse
### logfmt -r (reverse)
accepts JSON on STDIN and converts them to logfmt
echo '{ "foo": "bar", "a": 14, "baz": "hello kitty", "cool%story": "bro", "f": true, "%^asdf": true }' | logfmt -r
> echo '{ "foo": "bar", "a": 14, "baz": "hello kitty", "cool%story": "bro", "f": true, "%^asdf": true }' | logfmt -r
foo=bar a=14 baz="hello kitty" cool%story=bro f=true %^asdf=true
echo "foo=bar a=14 baz=\"hello kitty\" cool%story=bro f %^asdf" | logfmt | logfmt -r | logfmt
> echo "foo=bar a=14 baz=\"hello kitty\" cool%story=bro f %^asdf" | logfmt | logfmt -r | logfmt
{ "foo": "bar", "a": 14, "baz": "hello kitty", "cool%story": "bro", "f": true, "%^asdf": true }

Sorry, the diff of this file is not supported yet

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