在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:koajs/trace开源软件地址:https://github.com/koajs/trace开源编程语言:JavaScript 100.0%开源软件介绍:Koa TraceA generic tracing module.
Use app.use(async function (ctx, next) {
// give each request some sort of ID
ctx.id = crypto.randomBytes(12)
// log events with optional arguments
ctx.trace('start')
await next()
ctx.trace('finish')
}) Enable debug usage: app.debug() Now run your app with You can see the debug statements grouped by request ID.
Then the event is shown, the time difference since the last statement,
and the arguments passed to BackgroundI want to add something like this to Koa, but we're not sure what the best way possible is. Please provide feedback on this module, including suggestions or criticisms. I'm sure the debug usage could use a lot of work. ConventionThere are no conventions as to how to name your This module is backend agnostic. There is no possible way to support all the features of all the different backends. If you want to use backend specific stuff, you might as well use a module specific to it! If you want to create a convention, let me know! We can start a doc or wiki or something. APIrequire('koa-trace')(app)Add the instrumentation methods to const Koa = require('koa')
const app = new Koa()
require('koa-trace')(app) this.trace(event, args...)Emit an app.use(async function (ctx, next) {
ctx.trace('something', 1, 2, 3)
await next()
}) app.instrument(function (context, event, date, args) {})Listen to all the trace calls.
Any backends will need to use this method to hook into the trace calls. app.debug()Enable all the debug logging. This is not enabled by default, so you might want to do something like: if (process.env.NODE_ENV !== 'production') app.debug() To view all the debug logs,
run the node process with |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论