Skip to content

Commit

Permalink
fix: logging of first octokit instance is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
kammerjaeger committed May 26, 2022
1 parent 420f886 commit 269a614
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/octokit/get-probot-octokit-with-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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) {
Expand Down
20 changes: 20 additions & 0 deletions test/create-probot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
});
});

0 comments on commit 269a614

Please sign in to comment.