Namespace:
[Loom]::[Core]::[Console]> Class:ConsoleModule
The Console Module provides a standardized, color-coded logging interface. It replaces raw console.log calls to ensure consistent formatting across the application.
- Namespaces: Every log includes
[Namespace]to identify the source (e.g.,[Loom]::[Http]). - Color Coding: Success (Green), Info (Cyan), Warning (Yellow), Error (Red).
- JSON Support: Automatically detects and formats JSON objects.
All methods accept a body (message or object) and an optional args object { namespace: string }.
Prints a green success message.
deps.console.success('Connected to DB', { namespace: this._namespace });Prints a cyan info message.
deps.console.info('Processing request...', { namespace: this._namespace });Prints a yellow warning.
deps.console.warning('Retrying connection...', { namespace: this._namespace });Prints a red error message.
deps.console.error(errorObject, { namespace: this._namespace });Standard log without specific color coding.
Always use the injected console instead of the global one.
class UserService {
constructor(deps) {
this._console = deps.console;
this._namespace = '[UserModule]';
}
createUser() {
this._console.info('Creating user', { namespace: this._namespace });
}
}