A beautiful console.log wrapper
npm install @plopix/js-consoleThis package is a wrapper of console.log that enables outputs depending a Verbosity level that:
- you can set in the source code
- you can override via LocalStorage using the key: plopix.console.verbosity
Inject the library in your code:
``html`
You have now access to PlopixConsole globally.
Just use it!
> Have a look in the example.
In addition to the method provided by the LoggerInterface you also have
`typescript `
groupStart(title: string): void;
groupEnd(): void;
dir(data: any): void;
table(data: any): void;
clear(): void;
memory(): void;
trace(): void;
> They won't display anything if the Browser does not support it.
If you want to log things on the page load, you can use a specific HTML tag.
`html`
> Have a look in the example.
`typescript`
export enum Level {
EMERGENCY = 600,
ALERT = 550,
CRITICAL = 500,
ERROR = 400,
WARNING = 300,
NOTICE = 250,
INFO = 200,
DEBUG = 100,
SUCCESS = 0
}
> Can be used with Level.* in TypeScript
`typescript
export interface LoggerInterface {
// Logs with an arbitrary level.
log(level: Level, message: string, context?: any): void;
// System is unusable.
emergency(message: string, context?: any): void;
// Action must be taken immediately.
alert(message: string, context?: any): void;
// Critical conditions.
critical(message: string, context?: any): void;
// Runtime errors that do not require immediate action but should typically be logged and monitored.
error(message: string, context?: any): void;
// Exceptional occurrences that are not errors.
warning(message: string, context?: any): void;
// Normal but significant events.
notice(message: string, context?: any): void;
// Interesting events.
info(message: string, context?: any): void;
// Detailed debug information.
debug(message: string, context?: any): void;
// When all is good
success(message: string, context?: any): void;
}
``
Project under the MIT License (MIT)