Logging/src/test.ts

54 lines
1.7 KiB
TypeScript
Raw Normal View History

2019-11-17 15:44:57 +00:00
import { Logging, LoggingBase, LoggingTypes, Colors, withColor } from ".";
2019-04-02 23:55:04 +00:00
2020-04-06 09:47:59 +00:00
Logging.log("test");
2019-04-02 23:55:04 +00:00
Logging.log("i", "am", { a: "an" }, 1000);
Logging.error(new Error("fehler 001"));
Logging.debug("Some Debug infos");
Logging.errorMessage("i", "am", "an", "error");
2020-04-06 09:47:59 +00:00
Logging.log(
"\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m\x1b[31m TEST \x1b[31m\x1b[31m\x1b[31m"
);
2019-04-02 23:55:04 +00:00
2020-04-06 09:47:59 +00:00
Logging.log(
withColor(Colors.MAGENTA, "This text should be magenta!"),
"This not!"
);
Logging.log(withColor(Colors.MAGENTA, { somekey: "Some value" }));
2019-11-17 15:03:58 +00:00
2020-04-06 09:47:59 +00:00
let err = new Error();
if (typeof err.stack !== "string") console.log("Stacktrace invalid", err.stack);
2019-04-02 23:55:04 +00:00
let cus = new LoggingBase({ name: "test" });
2020-04-06 09:47:59 +00:00
cus.log("Hello from custom Logger");
2019-04-05 02:22:52 +00:00
cus.log("This has some %c symbols inside of it!");
2019-04-02 23:55:04 +00:00
let cus2 = new LoggingBase("test2");
2020-04-06 09:47:59 +00:00
cus2.log("Hello from custom Logger 2");
2019-04-02 23:55:04 +00:00
let cus22 = new LoggingBase("test2");
2020-04-06 09:47:59 +00:00
cus22.log("Hello from custom Logger 22");
cus2.log("Hello from custom Logger 2");
cus22.log("Hello from custom Logger 22");
cus2.log("Hello from custom Logger 2");
cus22.log("Hello from custom Logger 22");
cus2.log("Hello from custom Logger 2");
cus22.log("Hello from custom Logger 22");
cus2.log("Hello from custom Logger 2");
cus22.log("Hello from custom Logger 22");
cus2.log("Hello from custom Logger 2");
Logging.debug("Only Errors should appear:");
2019-07-13 10:10:20 +00:00
Logging.logLevel = LoggingTypes.Error;
Logging.debug("This should not be there 1");
Logging.log("This should not be there 2");
Logging.warn("This should not be there 3");
Logging.warning("This should not be there 4");
Logging.error("This should be there 1");
2020-04-06 09:47:59 +00:00
Logging.errorMessage("This should be there 2");
const timer = Logging.time("timer1", "Test Timer");
setTimeout(() => timer.end(), 1000);