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

Add new logger with log levels #435

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix after merge
  • Loading branch information
timokoessler committed Dec 20, 2024
commit 7559a48aa10e842a3e4e879bf5b7e98bce9bc9ca
6 changes: 4 additions & 2 deletions library/agent/hooks/wrapNewInstance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ t.test("Errors in interceptor are caught", async (t) => {

const instance = new exports.test("input");
t.same(instance.getInput(), "input");
t.same(logger.getMessages(), ["Failed to wrap method test in module test"]);
t.same(logger.getMessages(), [
"Failed to wrap method test in module test: test error",
]);
});

t.test("Return value from interceptor is returned", async (t) => {
Expand Down Expand Up @@ -162,6 +164,6 @@ t.test("Logs error when wrapping default export", async (t) => {
const instance = new exports("input");
t.same(instance.getInput(), "input");
t.same(logger.getMessages(), [
"Failed to wrap method default export in module test",
"Failed to wrap method default export in module test: test error",
]);
});
11 changes: 7 additions & 4 deletions library/agent/hooks/wrapNewInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ export function wrapNewInstance(
return returnVal;
}
} catch (error) {
agent.onFailedToWrapMethod(
pkgInfo.name,
className || "default export"
);
if (error instanceof Error) {
agent.onFailedToWrapMethod(
pkgInfo.name,
className || "default export",
error
);
}
}

return newInstance;
Expand Down
Loading