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

Disable Request Logging #1940

Open
ajhenry opened this issue Dec 18, 2023 · 9 comments
Open

Disable Request Logging #1940

ajhenry opened this issue Dec 18, 2023 · 9 comments

Comments

@ajhenry
Copy link

ajhenry commented Dec 18, 2023

Bug Report

Current Behavior
I want to standardize all my outputs to be JSON so that log processors like fluentbit will be able to consume them and format them properly.

There currently exists a hook that requests all logging and I want a way to disable it.

https://github.com/probot/probot/blob/master/src/octokit/octokit-plugin-probot-request-logging.ts

Expected behavior/code

No more log output from requests

Environment

  • Probot version(s): 12.3.3
  • Node/npm version: Node 18
  • OS: OSX 14

Possible Solution

We can add a configuration option to disable request logging

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

Copy link

welcome bot commented Dec 18, 2023

Thanks for opening this issue. A contributor should be by to give feedback soon. In the meantime, please check out the contributing guidelines and explore other ways you can get involved.

@AaronDewes
Copy link
Member

Not sure if it's helpful, but if NODE_ENV is set to production, probot will only log JSON: https://probot.github.io/docs/logging/#log-formats.

In addition, you can overwrite the logger with the log property if you do

   new Probot({
    log: myLogger,
    ...probotOptions,
  });

Here's a helper function we use internally for this: https://github.com/probot/probot/blob/master/src/helpers/alias-log.ts

@ajhenry
Copy link
Author

ajhenry commented Dec 19, 2023

@AaronDewes I found that even in production it still pretty prints an output 🤔

This may be because it's not logging at the probot/context level but instead at the octokit level.

There's a request logger plugin that is applied to the octokit instance that always pretty prints for me: https://github.com/probot/probot/blob/master/src/octokit/octokit-plugin-probot-request-logging.ts and here's where it gets applied

probotRequestLogging,

@AaronDewes
Copy link
Member

Can you check if this also happens on v13.0.0-beta.16?

@ajhenry
Copy link
Author

ajhenry commented Dec 19, 2023

I tried out v13.0.0-beta.16 and the issue still presents as well as introducing a slew of type errors 🙁

@ajhenry
Copy link
Author

ajhenry commented Dec 19, 2023

Is there a way to replace the octokit instance? That way I can pass in an octokit with that plugin removed

@ajhenry
Copy link
Author

ajhenry commented Dec 19, 2023

I was able to swap out the logging instance on the Octokit by passing in some default options.

import app from "bot";
import { createNodeMiddleware, createProbot, Logger } from "probot";
import { logger } from "utils/logger";

export const probot = createProbot();

export default createNodeMiddleware(app, {
  probot: createProbot({
    defaults: {
      log: {
        child: () => logger.getSubLogger({ name: "probot" }),
      } as any as Logger,
    },
  }),
  webhooksPath: "/api/webhooks",
});

Thanks for the help @AaronDewes

@wolfy1339
Copy link
Collaborator

I tried out v13.0.0-beta.16 and the issue still presents as well as introducing a slew of type errors 🙁

Some may be normal as we are shipping some breaking changes. There isn't a changelog as of yet, but if you look at the PR #1874 it should give you a good idea.

If you have any questions/issues, please feel free to make a new issue for that.

@Uzlopak
Copy link
Collaborator

Uzlopak commented Jan 4, 2024

Imho you need to set the log level to silent or error

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

4 participants