28 lines
773 B
TypeScript
28 lines
773 B
TypeScript
import Logging, { LoggingConfiguration } from "@proxnet/undead-logging";
|
|
|
|
class CustomError extends Error {
|
|
|
|
someProperty: string
|
|
|
|
constructor(someProp: string) {
|
|
super("Something went wrong.");
|
|
this.someProperty = someProp;
|
|
}
|
|
|
|
}
|
|
|
|
LoggingConfiguration.clearConversions();
|
|
LoggingConfiguration.addConversion<CustomError>({
|
|
condition: arg => arg instanceof CustomError,
|
|
converter: arg => `CustomError: someProperty:${arg.someProperty}; ${arg.stack || arg.message}`,
|
|
priority: -1
|
|
});
|
|
LoggingConfiguration.addConversion<Error>({
|
|
condition: arg => arg instanceof Error,
|
|
converter: arg => `Error: ${arg.stack || arg.message}`,
|
|
priority: 1
|
|
});
|
|
|
|
const log = new Logging("PriorityTest");
|
|
|
|
log.i(new CustomError("'Hello World!'")); |