Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ jobs:
run: yarn coverage
- name: Report coverage
uses: codecov/codecov-action@v3
tests-bun:
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2

- run: bun install
- run: bun test Nodejs
4 changes: 3 additions & 1 deletion src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export class Logger<Meta extends ILogObjMeta = ILogObjMeta> {
constructor(options?: ILogOptionsParam<Meta>, transports?: ITransport[], private stackDepthLevel: number = 4) {
const isBrowser = ![typeof window, typeof document].includes("undefined");
const isSafari = isBrowser ? /^((?!chrome|android).)*safari/i.test(navigator?.userAgent) : false;
this.stackDepthLevel = isSafari ? 4 : this.stackDepthLevel;
const isBun = "Bun" in globalThis;

this.stackDepthLevel = isSafari ? 4 : isBun ? 3 : this.stackDepthLevel;

this.attachedTransports = transports || [new PrettyPrinterTransport(ConsoleSink, {})];
this.options = {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function stackLineToStackFrame(line?: string): IStackFrame {
method: undefined,
};
if (line != null) {
const match = line.match(pathRegex);
const match = line.replaceAll("\\", "/").match(pathRegex);
if (match) {
pathResult.fullFilePath = match[1].replace(/\?.*$/, "");
const pathParts = pathResult.fullFilePath.split("/");
Expand Down
2 changes: 1 addition & 1 deletion tests/Nodejs/2_pretty_loglevel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const logger = new Logger();

describe("Pretty: Log level", () => {
beforeEach(() => {
mockConsoleLog(true, true);
mockConsoleLog(true, false);
});

test("silly (console)", (): void => {
Expand Down
4 changes: 2 additions & 2 deletions tests/Nodejs/5_pretty_Log_Types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("Pretty: Log Types", () => {
expect(getConsoleOutput()).toContain("test");
expect(getConsoleOutput()).toContain("error stack:\n");
expect(getConsoleOutput()).toContain("5_pretty_Log_Types.test.ts");
expect(getConsoleOutput()).toContain("Object.<anonymous>");
expect(getConsoleOutput()).toContain("<anonymous>");
});

test("string and Error", (): void => {
Expand All @@ -96,6 +96,6 @@ describe("Pretty: Log Types", () => {
expect(getConsoleOutput()).toContain("test");
expect(getConsoleOutput()).toContain("error stack:\n");
expect(getConsoleOutput()).toContain("5_pretty_Log_Types.test.ts");
expect(getConsoleOutput()).toContain("Object.<anonymous>");
expect(getConsoleOutput()).toContain("<anonymous>");
});
});
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"$schema": "http://json.schemastore.org/tsconfig",
"compileOnSave": false,
"compilerOptions": {
"lib": ["es2020", "dom"],
"target": "es2020",
"lib": ["ES2021", "dom"],
"target": "ES2021",
"module": "CommonJS",
"moduleResolution": "Node",
"types": ["node", "jest", "puppeteer", "jest-environment-puppeteer", "expect-puppeteer"],
Expand Down