Comparing version 0.9.1 to 0.9.2
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21359
177
366