Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to disable or replacing logging? #281

Open
oscarcalderonc opened this issue Jul 6, 2023 · 1 comment
Open

Is there a way to disable or replacing logging? #281

oscarcalderonc opened this issue Jul 6, 2023 · 1 comment

Comments

@oscarcalderonc
Copy link

oscarcalderonc commented Jul 6, 2023

I'm currently using serverless-http ~2.5.0 in an existing project. By default it seems it logs every request start and end, along with a big JSON containing the request information (headers, JWT, etc). I want to either be able to customize this logging or to disable entirely to be able to use another solution like Pino. An example:

ANY /my/endpoint (λ: app)
Executing (default): SELECT 1+1 AS result
{
   "level":30,
   "time":1688651877670,
   "pid":10859,
   "hostname":"123",
   "req":{
      "id":1,
      "method":"GET",
      "url":"/my/endpoint",
      "query":{
         
      },
      "params":{
         
      },
      "headers":{
         "host":"localhost:8000",
         "user-agent":"insomnia/2023.3.0",
         "authorization":"Bearer [TOKEN]",
         "accept":"*/*",
         "x-request-id":"cljr7q68s0001b1rm2xxo3dl2",
         "content-length":0
      },
      "remoteAddress":"127.0.0.1"
   },
   "res":{
      "statusCode":401,
      "headers":{
         "content-security-policy":"default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests",
         "x-dns-prefetch-control":"off",
         "expect-ct":"max-age=0",
         "x-frame-options":"SAMEORIGIN",
         "strict-transport-security":"max-age=15552000; includeSubDomains",
         "x-download-options":"noopen",
         "x-content-type-options":"nosniff",
         "x-permitted-cross-domain-policies":"none",
         "referrer-policy":"no-referrer",
         "x-xss-protection":"0",
         "vary":"Origin",
         "content-type":"application/json; charset=utf-8",
         "content-length":"25",
         "etag":"W/\"19-NLxHdTmGtBwpH6O42txxhQPNwcM\""
      }
   },
   "responseTime":709,
   "msg":"request aborted"
}
(λ: app) RequestId: cljr7q68t0002b1rmbxmw56xi  Duration: 2058.92 ms  Billed Duration: 2059 ms

How can I achieve this? The documentation is not so clear about this. It seems I can bass an options object to the serverless handler but I cannot see an option to customize or disable logging.

@dougmoscrop
Copy link
Owner

Sorry but this doesn't appear to be coming from serverless-http?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants