Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "logfmt", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Key-Value log line parser", | ||
@@ -5,0 +5,0 @@ "main": "logfmt.js", |
# node-logfmt | ||
## install | ||
npm install logfmt | ||
## use | ||
@@ -8,6 +12,6 @@ | ||
```javascript | ||
var logfmt = require('logfmt'), | ||
var logfmt = require('logfmt'); | ||
logfmt.parse("foo=bar a=14 baz=\"hello kitty\" cool%story=bro f %^asdf") | ||
//=>{ "foo": "bar", "a": 14, "baz": "hello kitty", "cool%story": "bro", "f": true, "%^asdf": true } | ||
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" } | ||
``` | ||
@@ -18,3 +22,3 @@ | ||
```javascript | ||
var logfmt = require('logfmt-body-parser'); | ||
var logfmt = require('logfmt').body_parser; | ||
@@ -24,4 +28,23 @@ app.use(logfmt()); | ||
// req.body is now an array of objects | ||
app.post('/logs', function(req, res){ | ||
console.log('BODY: ' + JSON.stringify(req.body)); | ||
req.body.forEach(function(data){ | ||
console.log(data); | ||
}); | ||
res.send('OK'); | ||
}) | ||
app.listen(3000) | ||
``` | ||
test it: | ||
```bash | ||
curl -X POST --header 'Content-Type: application/logplex-1' -d "foo=bar a=14 baz=\"hello kitty\" cool%story=bro f %^asdf" http://localhost:3000/logs | ||
``` | ||
### command line | ||
@@ -31,1 +54,6 @@ | ||
{ "foo": "bar", "a": 14, "baz": "hello kitty", "cool%story": "bro", "f": true, "%^asdf": true } | ||
## caveats | ||
I use a regex and haven't optimized much for performance yet. |
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
7099
56