Skip to content

Commit

Permalink
fix: fixed performance log
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrodev07 committed Feb 23, 2024
1 parent 3e79c0e commit 60af498
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kittylog",
"version": "1.0.4",
"version": "1.0.5",
"description": "Pretty logs in JavaScript",
"author": "pietrodev07",
"main": "dist/index.js",
Expand Down
12 changes: 8 additions & 4 deletions src/functions/group/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ import { Color, GroupType } from "../../types";

export const group = (title: string, color?: Color, type: GroupType = "NORMAL") => {
const { colorizeText, buildCompleteMessage } = colorsProvider;

const selectedColor = color in COLORS ? COLORS[color] : COLORS.magenta;
const label = colorizeText(`[${title}]`, selectedColor);
const completeMessage = buildCompleteMessage([label]);

if (type === "NORMAL") {
console.group(...completeMessage);
} else {
console.groupCollapsed(...completeMessage);
}
};

export const groupEnd = () => {
console.groupEnd();
};
return {
end: () => {
console.groupEnd();
}
};
};
2 changes: 1 addition & 1 deletion src/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { input } from "./input/input";
export { debug } from "./debug/debug";
export { error } from "./error/error";
export { group, groupEnd } from "./group/group";
export { group } from "./group/group";
export { httpResponse } from "./httpResponse/httpResponse";
export { info } from "./info/info";
export { performance } from "./performance/performance";
Expand Down
8 changes: 6 additions & 2 deletions src/test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { kittylog } from "./index";

const group = kittylog.group("Group #1", "blue");

kittylog.info("Info...");
kittylog.success("Success...");
kittylog.warning("Warn...");
kittylog.error("Error...");
kittylog.custom("magenta", "CUSTOM", "Custom...");

group.end();

kittylog.blank("dashed", "yellow");
kittylog.error(new Error("Error..."));

Expand All @@ -27,11 +31,11 @@ whileLoopTest.end();

const forLoopTest = kittylog.performance("external performance test #2");

for (let i = 0; i < 100; i++) {}
for (let i = 0; i < 100; i++) { }

const internalTest = kittylog.performance("internal performance test");

for (let i = 0; i < 100; i++) {}
for (let i = 0; i < 100; i++) { }

internalTest.end();

Expand Down

0 comments on commit 60af498

Please sign in to comment.