V3
This commit is contained in:
43
src/test.ts
43
src/test.ts
@ -1,26 +1,19 @@
|
||||
import {
|
||||
Logging,
|
||||
LoggingBase,
|
||||
LoggingTypes,
|
||||
Colors,
|
||||
withColor,
|
||||
} from "./index.js";
|
||||
import Logging from "./index.js";
|
||||
|
||||
import { Logging as LoggingBase, LoggingTypes, Format } from "./index.js";
|
||||
|
||||
Logging.log("test");
|
||||
Logging.log("i", "am", { a: "an" }, 1000);
|
||||
Logging.error(new Error("fehler 001"));
|
||||
Logging.debug("Some Debug infos");
|
||||
Logging.errorMessage("i", "am", "an", "error");
|
||||
Logging.error("i", "am", "an", "error");
|
||||
|
||||
Logging.log(
|
||||
"\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m TEST \x1b[31m\x1b[31m\x1b[31m"
|
||||
);
|
||||
|
||||
Logging.log(
|
||||
withColor(Colors.MAGENTA, "This text should be magenta!"),
|
||||
"This not!"
|
||||
);
|
||||
Logging.log(withColor(Colors.MAGENTA, { somekey: "Some value" }));
|
||||
Logging.log(Format.magenta("This text should be magenta!"), "This not!");
|
||||
Logging.log(Format.magenta({ somekey: "Some value" }));
|
||||
|
||||
let err = new Error();
|
||||
if (typeof err.stack !== "string") console.log("Stacktrace invalid", err.stack);
|
||||
@ -29,10 +22,10 @@ let cus = new LoggingBase({ name: "test" });
|
||||
cus.log("Hello from custom Logger");
|
||||
cus.log("This has some %c symbols inside of it!");
|
||||
|
||||
let cus2 = new LoggingBase("test2");
|
||||
let cus2 = new LoggingBase({ name: "test2" });
|
||||
cus2.log("Hello from custom Logger 2");
|
||||
|
||||
let cus22 = new LoggingBase("test2");
|
||||
let cus22 = new LoggingBase({ name: "test2" });
|
||||
cus22.log("Hello from custom Logger 22");
|
||||
cus2.log("Hello from custom Logger 2");
|
||||
cus22.log("Hello from custom Logger 22");
|
||||
@ -53,7 +46,9 @@ Logging.warn("This should not be there 3");
|
||||
Logging.warning("This should not be there 4");
|
||||
|
||||
Logging.error("This should be there 1");
|
||||
Logging.errorMessage("This should be there 2");
|
||||
Logging.error("This should be there 2");
|
||||
|
||||
Logging.logLevel = LoggingTypes.Debug;
|
||||
|
||||
const c1 = Logging.getChild("child-level-1");
|
||||
|
||||
@ -63,25 +58,11 @@ const c2 = c1.getChild("child-level-2");
|
||||
|
||||
c2.log("Hello from Child 2");
|
||||
|
||||
c2.addAdapter({
|
||||
init: (obs) =>
|
||||
obs.subscribe((msg) =>
|
||||
console.log(
|
||||
"Adapter adden on child level 2: ",
|
||||
"---",
|
||||
msg.name,
|
||||
msg.text.raw
|
||||
)
|
||||
),
|
||||
flush: () => undefined,
|
||||
close: () => undefined,
|
||||
});
|
||||
|
||||
c2.log("MSG from C2");
|
||||
c1.log("MSG from C1");
|
||||
Logging.log("MSG from root");
|
||||
|
||||
const timer = Logging.time("timer1", "Test Timer");
|
||||
const timer = Logging.time("timer1");
|
||||
setTimeout(() => timer.end(), 1000);
|
||||
|
||||
const withoutFile = new LoggingBase({
|
||||
|
Reference in New Issue
Block a user