File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,17 @@ import { HTTPException } from "@hono/hono/http-exception";
33import { logger } from "@hono/hono/logger" ;
44
55import config from "./config.ts" ;
6- import { contextMiddleware } from "./context.ts" ;
6+ import { contextMiddleware , getRequestLog } from "./context.ts" ;
77import { hasKey , verify } from "./crypto.ts" ;
88import handler from "./handler.ts" ;
99
1010const app = new Hono ( ) ;
1111
12- app . use ( logger ( ) ) ;
1312app . use ( contextMiddleware ) ;
1413
14+ // use context's requestlog for server logs
15+ app . use ( logger ( ( ...args ) => getRequestLog ( ) . log ( ...args ) ) ) ;
16+
1517if ( config . mainRedirect ) {
1618 app . get ( "/" , ( c ) => {
1719 return c . redirect ( config . mainRedirect ! ) ;
Original file line number Diff line number Diff line change @@ -32,14 +32,13 @@ export function wildcardMatch(pattern: string, target: string): boolean {
3232 * logging proxy that adds some metadata to log messages
3333 */
3434export function requestLog ( deliveryId : string | undefined ) {
35- const prefix = deliveryId ? `[${ deliveryId } ] ` : "" ;
35+ const prefix = deliveryId ? `[${ deliveryId } ]` : "" ;
3636
3737 // ugh
3838 // is there a better way to do this? certainly.
3939 // does this work? also yes.
40- const proxyLog : ( func : ( s : any ) => void ) => ( msg : any ) => void = ( func ) => {
41- // FIXME: `String()` mangles objects
42- return ( msg ) => func ( prefix + String ( msg ) ) ;
40+ const proxyLog : ( func : ( ...args : any [ ] ) => void ) => ( ...args : any [ ] ) => void = ( func ) => {
41+ return ( ...args ) => func ( prefix , ...args ) ;
4342 } ;
4443
4544 return {
You can’t perform that action at this time.
0 commit comments