LoggerService
katanakit-js / LoggerService
Class: LoggerService
Section titled “Class: LoggerService”Defined in: core/services/logger.service.ts:7
LoggerService - Singleton para logging Aplica el patrón Singleton para garantizar una única instancia de logger.
Methods
Section titled “Methods”useClear()
Section titled “useClear()”useClear(): void;Defined in: core/services/logger.service.ts:104
Clears the console.
Returns
Section titled “Returns”void
Example
Section titled “Example”useLoggerClear();useLog()
Section titled “useLog()”useLog( message, data?, level?): void;Defined in: core/services/logger.service.ts:58
Logs a message with optional data and level.
Maps directly onto the native console methods (log, warn, error).
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
message |
string |
undefined |
The message to log. |
data? |
unknown |
undefined |
Optional data to attach to the log. |
level? |
"error" | "log" | "warn" |
"log" |
The log level. Defaults to "log". |
Returns
Section titled “Returns”void
Example
Section titled “Example”import { useLogger } from "katanakit-js";
useLogger("Application started");useLogger("Cache miss", undefined, "warn");useLogger("Database timeout", { query: "SELECT 1" }, "error");useLogError()
Section titled “useLogError()”useLogError(message, data?): void;Defined in: core/services/logger.service.ts:92
Logs a message at the “error” level.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
message |
string |
The message to log. |
data? |
unknown |
Optional error data to attach to the log. |
Returns
Section titled “Returns”void
Example
Section titled “Example”useLogError("Database timeout", { query: "SELECT 1", duration: 5000 });useLogWarn()
Section titled “useLogWarn()”useLogWarn(message, data?): void;Defined in: core/services/logger.service.ts:77
Logs a message at the “warn” level.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
message |
string |
The message to log. |
data? |
unknown |
Optional data to attach to the log. |
Returns
Section titled “Returns”void
Example
Section titled “Example”useLogWarn("Cache miss", { key: "user:123" });useSetContext()
Section titled “useSetContext()”useSetContext(context): void;Defined in: core/services/logger.service.ts:32
Configura el prefijo de contexto. Vacío (“”) lo elimina.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context |
string |
Returns
Section titled “Returns”void
useTable()
Section titled “useTable()”useTable(data): void;Defined in: core/services/logger.service.ts:118
Displays tabular data in the console.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
data |
unknown |
The data to display as a table. |
Returns
Section titled “Returns”void
Example
Section titled “Example”useLoggerTable([{ id: 1, name: "Alice" }, { id: 2, name: "Bob" }]);getInstance()
Section titled “getInstance()”static getInstance(): LoggerService;Defined in: core/services/logger.service.ts:22
Obtiene la instancia única del LoggerService (Singleton)
Returns
Section titled “Returns”LoggerService