forked from mirrors/probot
fix: logging of first octokit instance is not set (#1676) - thanks @kammerjaeger @markjm
This commit is contained in:
parent
7fd06d6975
commit
646b6a9276
|
@ -3,6 +3,7 @@ import { ProbotOctokit } from "./probot-octokit";
|
|||
import Redis from "ioredis";
|
||||
|
||||
import { getOctokitThrottleOptions } from "./get-octokit-throttle-options";
|
||||
import { aliasLog } from "../helpers/alias-log";
|
||||
|
||||
import type { Logger } from "pino";
|
||||
|
||||
|
@ -45,6 +46,9 @@ export function getProbotOctokitWithDefaults(options: Options) {
|
|||
|
||||
let defaultOptions: any = {
|
||||
auth: authOptions,
|
||||
log: options.log.child
|
||||
? aliasLog(options.log.child({ name: "octokit" }))
|
||||
: options.log,
|
||||
};
|
||||
|
||||
if (options.baseUrl) {
|
||||
|
|
|
@ -80,4 +80,24 @@ describe("createProbot", () => {
|
|||
});
|
||||
expect(JSON.parse(outputData).myMessage).toEqual("Ciao");
|
||||
});
|
||||
|
||||
test("env, octokit logger set", async () => {
|
||||
const outputData = await captureLogOutput(async () => {
|
||||
const probot = createProbot({
|
||||
env: {
|
||||
...env,
|
||||
LOG_LEVEL: "info",
|
||||
LOG_FORMAT: "json",
|
||||
LOG_MESSAGE_KEY: "myMessage",
|
||||
},
|
||||
});
|
||||
|
||||
const octokit = await probot.auth();
|
||||
octokit.log.info("Ciao");
|
||||
});
|
||||
expect(JSON.parse(outputData)).toMatchObject({
|
||||
myMessage: "Ciao",
|
||||
name: "octokit",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue