koajs / bunyan-logger Goto Github PK
View Code? Open in Web Editor NEWKoa middleware for bunyan request logging
License: MIT License
Koa middleware for bunyan request logging
License: MIT License
I am using Typescript in my Koa project and want to use bunyan logging -- when I import the module Typescript is complaining of a missing definition's file (because -- well -- one is). Any chance we can add such a file?
Is there a way to disable logging for static assets? Thanks.
package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.
This file is intended to be committed into source repositories, and serves various purposes:
Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
Provide a facility for users to "time-travel" to previous states of node_modules without having to commit the directory itself.
To facilitate greater visibility of tree changes through readable source control diffs.
And optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages.
One key detail about package-lock.json is that it cannot be published, and it will be ignored if found in any place other than the toplevel package. It shares a format with npm-shrinkwrap.json(5), which is essentially the same file, but allows publication. This is not recommended unless deploying a CLI tool or otherwise using the publication process for producing production packages.
If both package-lock.json and npm-shrinkwrap.json are present in the root of a package, package-lock.json will be completely ignored.
how can i config set any spec path to ignore request logger?
We need to add the ignorePaths option and example to the documentation before we release...
And the current Master tagged Koa-1 or something? It's very weird and unusual not to have the latest NPM published version NOT be master. This is rather odd to me.
@aheckmann or @jlai --
@oleg-koval and I (Mostly Ed!) have a new release ready for NPM. However, we don't have the authority to push a new release. :(
Can someone fix this so we can actually publish the release? My NPM login in sjmcdowall not sure what Ed's (oleg-koval) is .
Thanks!
For security reasons I'd like to not log cookie headers. Since updateLogFields
mutates ctx
, this means I end up stripping headers from requests -- and I need those, just not in the logs. Would you be open to a PR that deep clones ctx
when it goes into the update functions? I have a little wrapper in my own code that strips out log fields before actually logging somewhere, but it feels like something that belongs in the library.
Hello,
I'd like to know if this repository is still being maintained.
There are some automated PRs to update dependencies still open.
I'd like to contribute to what I think is an issue with the format of the logs but first I'd like to see if someone could actually validate my changes, merge them and do a release.
Thanks,
Jorge
personally, I prefer this linter rules: https://github.com/markelog/eslint-config-sexy
but its, of course, open for discussion :)
Would be nice to add a version for Koa 2 with promises! :)
I have specified my own bunyan instance which is a child component with its own level. However, If I set the level to info
, I still get the amount of logging I would expect with debug
or trace
(it logs the req
object). If I don't specify my own bunyan instance at all, then I get the expected output of just the request parameters and not the entire req
object.
Node v6.7.0
Bunyan 1.8.1
Koa 2.0.0-alpha.7
koa-bunyan-logger 2.0.0-pre1
let logger = bunyan.createLogger({
name: 'website',
stream: process.stdout,
level: 'debug'
})
logger.req = logger.child({
component: 'req',
level: 'info'
})
app.use(koaBunyanLogger(logger.req))
app.use(koaBunyanLogger.requestIdContext())
app.use(koaBunyanLogger.requestLogger())
[2016-10-02T00:37:13.505Z] INFO: website/req/24532 on vm: <-- GET /api (req_id=399c55dc-eaa6-4418-8ee8-d6499f3aaebb, req.readable=true, req.domain=null, req._events={}, req._eventsCount=0, req.connection=[Circular], req.httpVersionMajor=1, req.httpVersionMinor=1, req.complete=false, req.rawTrailers=[], req.upgrade=false, req.statusCode=null, req.statusMessage=null, req.client=[Circular], req._consuming=false, req._dumped=false)
GET /api HTTP/1.1
host: 127.0.0.1:3000
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,text/csv;q=0.9
accept-language: en-US,en;q=0.5
accept-encoding: gzip, deflate
dnt: 1
connection: keep-alive
upgrade-insecure-requests: 1
cache-control: max-age=0
--
req._readableState: {
"objectMode": false,
"highWaterMark": 16384,
"buffer": {
"head": null,
"tail": null,
"length": 0
},
"length": 0,
"pipes": null,
"pipesCount": 0,
"flowing": null,
"ended": false,
"endEmitted": false,
"reading": false,
"sync": true,
"needReadable": false,
"emittedReadable": false,
"readableListening": false,
"resumeScheduled": false,
"defaultEncoding": "utf8",
"ranOut": false,
"awaitDrain": 0,
"readingMore": true,
"decoder": null,
"encoding": null
}
--
req.socket: {
"connecting": false,
"_hadError": false,
"_handle": {
"bytesRead": 376,
"_externalStream": {},
"fd": 22,
"reading": true,
"owner": "[Circular]",
"onconnection": null,
"writeQueueSize": 0
},
"_parent": null,
"_host": null,
"_readableState": {
"objectMode": false,
"highWaterMark": 16384,
"buffer": {
"head": null,
"tail": null,
"length": 0
},
"length": 0,
"pipes": null,
"pipesCount": 0,
"flowing": true,
"ended": false,
"endEmitted": false,
"reading": true,
"sync": false,
"needReadable": true,
"emittedReadable": false,
"readableListening": false,
"resumeScheduled": false,
"defaultEncoding": "utf8",
"ranOut": false,
"awaitDrain": 0,
"readingMore": false,
"decoder": null,
"encoding": null
},
"readable": true,
"domain": null,
"_events": {
"end": [
null,
null
],
"drain": [
null,
null
],
"error": [
null,
null
],
"close": [
null,
null,
null
]
},
"_eventsCount": 10,
"_writableState": {
"objectMode": false,
"highWaterMark": 16384,
"needDrain": false,
"ending": false,
"ended": false,
"finished": false,
"decodeStrings": false,
"defaultEncoding": "utf8",
"length": 0,
"writing": false,
"corked": 0,
"sync": true,
"bufferProcessing": false,
"writecb": null,
"writelen": 0,
"bufferedRequest": null,
"lastBufferedRequest": null,
"pendingcb": 0,
"prefinished": false,
"errorEmitted": false,
"bufferedRequestCount": 0,
"corkedRequestsFree": {
"next": null,
"entry": null
}
},
"writable": true,
"allowHalfOpen": true,
"destroyed": false,
"_bytesDispatched": 0,
"_sockname": null,
"_pendingData": null,
"_pendingEncoding": "",
"server": {
"domain": null,
"_events": {},
"_eventsCount": 2,
"_connections": 1,
"_handle": {
"bytesRead": 0,
"_externalStream": {},
"fd": 21,
"reading": false,
"owner": "[Circular]",
"onread": null,
"writeQueueSize": 0
},
"_usingSlaves": false,
"_slaves": [],
"_unref": false,
"allowHalfOpen": true,
"pauseOnConnect": false,
"httpAllowHalfOpen": false,
"timeout": 120000,
"_pendingResponseData": 0,
"_connectionKey": "4:127.0.0.1:3000"
},
"_server": "[Circular]",
"_idleTimeout": 120000,
"_idleNext": {
"_idleNext": "[Circular]",
"_idlePrev": "[Circular]",
"_timer": {
"_list": "[Circular]"
},
"_unrefed": true,
"msecs": 120000
},
"_idlePrev": "[Circular]",
"_idleStart": 13088,
"parser": {
"_headers": [],
"_url": "",
"_consumed": true,
"socket": "[Circular]",
"incoming": "[Circular]",
"outgoing": null,
"maxHeaderPairs": 2000
},
"_paused": false,
"_consuming": true,
"_httpMessage": {
"domain": null,
"_events": {
"finish": [
null,
null
]
},
"_eventsCount": 2,
"output": [],
"outputEncodings": [],
"outputCallbacks": [],
"outputSize": 0,
"writable": true,
"_last": false,
"upgrading": false,
"chunkedEncoding": false,
"shouldKeepAlive": true,
"useChunkedEncodingByDefault": true,
"sendDate": true,
"_removedHeader": {},
"_contentLength": null,
"_hasBody": true,
"_trailer": "",
"finished": false,
"_headerSent": false,
"socket": "[Circular]",
"connection": "[Circular]",
"_header": null,
"_headers": null,
"_headerNames": {},
"statusCode": 404
},
"_peername": {
"address": "127.0.0.1",
"family": "IPv4",
"port": 51787
}
}
--
req.rawHeaders: [
"Host",
"127.0.0.1:3000",
"User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0",
"Accept",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,text/csv;q=0.9",
"Accept-Language",
"en-US,en;q=0.5",
"Accept-Encoding",
"gzip, deflate",
"DNT",
"1",
"Connection",
"keep-alive",
"Upgrade-Insecure-Requests",
"1",
"Cache-Control",
"max-age=0"
]
[2016-10-02T00:37:13.525Z] INFO: website/req/24532 on vm: --> GET /api 200 14ms (req_id=399c55dc-eaa6-4418-8ee8-d6499f3aaebb, duration=14, req.readable=true, req.domain=null, req._events={}, req._eventsCount=0, req.connection=[Circular], req.httpVersionMajor=1, req.httpVersionMinor=1, req.complete=true, req.rawTrailers=[], req.upgrade=false, req.statusCode=null, req.statusMessage=null, req.client=[Circular], req._consuming=false, req._dumped=true, res.domain=null, res._eventsCount=1, res.output=[], res.outputEncodings=[], res.outputCallbacks=[], res.outputSize=0, res.writable=true, res._last=false, res.upgrading=false, res.chunkedEncoding=false, res.shouldKeepAlive=true, res.useChunkedEncodingByDefault=true, res.sendDate=true, res._contentLength=12, res._hasBody=true, res._trailer="", res.finished=true, res._headerSent=true, res.socket=null, res.connection=null, res.__onFinished=null, res.statusMessage=OK)
GET /api HTTP/1.1
host: 127.0.0.1:3000
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,text/csv;q=0.9
accept-language: en-US,en;q=0.5
accept-encoding: gzip, deflate
dnt: 1
connection: keep-alive
upgrade-insecure-requests: 1
cache-control: max-age=0
--
HTTP/1.1 200 OK
--
req._readableState: {
"objectMode": false,
"highWaterMark": 16384,
"buffer": {
"head": null,
"tail": null,
"length": 0
},
"length": 0,
"pipes": null,
"pipesCount": 0,
"flowing": true,
"ended": true,
"endEmitted": false,
"reading": false,
"sync": true,
"needReadable": false,
"emittedReadable": true,
"readableListening": false,
"resumeScheduled": true,
"defaultEncoding": "utf8",
"ranOut": false,
"awaitDrain": 0,
"readingMore": true,
"decoder": null,
"encoding": null
}
--
req.socket: {
"connecting": false,
"_hadError": false,
"_handle": {
"bytesRead": 376,
"_externalStream": {},
"fd": 22,
"reading": true,
"owner": "[Circular]",
"onconnection": null,
"writeQueueSize": 0
},
"_parent": null,
"_host": null,
"_readableState": {
"objectMode": false,
"highWaterMark": 16384,
"buffer": {
"head": null,
"tail": null,
"length": 0
},
"length": 0,
"pipes": null,
"pipesCount": 0,
"flowing": true,
"ended": false,
"endEmitted": false,
"reading": true,
"sync": false,
"needReadable": true,
"emittedReadable": false,
"readableListening": false,
"resumeScheduled": false,
"defaultEncoding": "utf8",
"ranOut": false,
"awaitDrain": 0,
"readingMore": false,
"decoder": null,
"encoding": null
},
"readable": true,
"domain": null,
"_events": {
"end": [
null,
null
],
"drain": [
null,
null
],
"error": [
null
],
"close": [
null
]
},
"_eventsCount": 10,
"_writableState": {
"objectMode": false,
"highWaterMark": 16384,
"needDrain": false,
"ending": false,
"ended": false,
"finished": false,
"decodeStrings": false,
"defaultEncoding": "utf8",
"length": 0,
"writing": false,
"corked": 0,
"sync": false,
"bufferProcessing": false,
"writecb": null,
"writelen": 0,
"bufferedRequest": null,
"lastBufferedRequest": null,
"pendingcb": 1,
"prefinished": false,
"errorEmitted": false,
"bufferedRequestCount": 0,
"corkedRequestsFree": {
"next": null,
"entry": null
}
},
"writable": true,
"allowHalfOpen": true,
"destroyed": false,
"_bytesDispatched": 153,
"_sockname": null,
"_pendingData": null,
"_pendingEncoding": "",
"server": {
"domain": null,
"_events": {},
"_eventsCount": 2,
"_connections": 1,
"_handle": {
"bytesRead": 0,
"_externalStream": {},
"fd": 21,
"reading": false,
"owner": "[Circular]",
"onread": null,
"writeQueueSize": 0
},
"_usingSlaves": false,
"_slaves": [],
"_unref": false,
"allowHalfOpen": true,
"pauseOnConnect": false,
"httpAllowHalfOpen": false,
"timeout": 120000,
"_pendingResponseData": 0,
"_connectionKey": "4:127.0.0.1:3000"
},
"_server": "[Circular]",
"_idleTimeout": 120000,
"_idleNext": {
"_idleNext": "[Circular]",
"_idlePrev": "[Circular]",
"_timer": {
"_list": "[Circular]"
},
"_unrefed": true,
"msecs": 120000
},
"_idlePrev": "[Circular]",
"_idleStart": 13120,
"parser": {
"_headers": [],
"_url": "",
"_consumed": true,
"socket": "[Circular]",
"incoming": "[Circular]",
"outgoing": null,
"maxHeaderPairs": 2000
},
"_paused": false,
"_consuming": true,
"_httpMessage": null,
"_peername": {
"address": "127.0.0.1",
"family": "IPv4",
"port": 51787
}
}
--
req.rawHeaders: [
"Host",
"127.0.0.1:3000",
"User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0",
"Accept",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,text/csv;q=0.9",
"Accept-Language",
"en-US,en;q=0.5",
"Accept-Encoding",
"gzip, deflate",
"DNT",
"1",
"Connection",
"keep-alive",
"Upgrade-Insecure-Requests",
"1",
"Cache-Control",
"max-age=0"
]
--
req._parsedUrl: {
"protocol": null,
"slashes": null,
"auth": null,
"host": null,
"port": null,
"hostname": null,
"hash": null,
"search": null,
"query": null,
"pathname": "/api",
"path": "/api",
"href": "/api",
"_raw": "/api"
}
--
res._events: {
"finish": [
null
]
}
--
res._removedHeader: {
"content-length": false
}
--
res._header: HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 12
Date: Sun, 02 Oct 2016 00:37:13 GMT
Connection: keep-alive
--
res._headers: {
"content-type": "text/plain; charset=utf-8",
"content-length": "12"
}
--
res._headerNames: {
"content-type": "Content-Type",
"content-length": "Content-Length"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.