### Install @workleap/logging package Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Installs the @workleap/logging package using pnpm. This is the first step to start using the logging functionalities. ```bash pnpm add @workleap/logging ``` -------------------------------- ### Send logs to LogRocket Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Demonstrates how to use the `LogRocketLogger` from either the `@workleap/telemetry` or `@workleap/logrocket` package to send log entries to LogRocket session replays. ```typescript import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new LogRocketLogger(); logger.debug("Application started!"); ``` -------------------------------- ### Compose multiple loggers for multi-destination logging Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Shows how to use `CompositeLogger` to forward log entries to multiple destinations simultaneously, such as the console and LogRocket. ```typescript import { BrowserConsoleLogger, CompositeLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new BrowserConsoleLogger(), new LogRocketLogger() ]); logger.debug("Application started!"); ``` -------------------------------- ### Create complex log entries with text, objects, and errors Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Illustrates how to build richer log entries by chaining methods to include text, objects, and error details before logging the message at the error level. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger .withText("Failed to process order") .withObject({ orderId: 12345 }) .withError(new Error("Payment declined")) .error(); ``` -------------------------------- ### Log entries spanning multiple lines Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Shows how to create a log entry that spans multiple lines by inserting line breaks between text segments using the `withLineChange()` method. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger .withText("First line") .withLineChange() .withText("Second line") .debug(); ``` -------------------------------- ### Install workleap-logging Agent Skill Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/use-with-agents.md Installs the workleap-logging agent skill using npx. This command adds the specified skill to your project or globally, making it available for agent interactions. ```bash npx skills add https://github.com/workleap/wl-logging --skill workleap-logging ``` -------------------------------- ### Log basic text messages Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Shows the simplest way to log a plain text message using the BrowserConsoleLogger at the debug level. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger.debug("Application started!"); ``` -------------------------------- ### Write console logs with different severity levels Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Demonstrates how to use the BrowserConsoleLogger to output log entries with various severity levels: debug, information, warning, error, and critical. This allows for filtering logs based on a minimum severity. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger.debug("Application started!"); logger.information("Application started!"); logger.warn("Application is slow to start."); logger.error("An error occurred while starting the application."); logger.critical("Application failed to start."); ``` -------------------------------- ### Create and use logging scopes Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Explains how to create logging scopes to group related log entries under a shared label or context, useful for tracing operations or correlating events. The scope is ended using `scope.end()`. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); const scope = logger.startScope("User signup"); scope.information("Form loaded"); scope.debug("User entered email"); scope. .withText("Failed to create account") .withError(new Error("Email is already used.")) .error(); scope.end(); ``` -------------------------------- ### Implement RootLogger Interface in TypeScript Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/RootLogger.md Demonstrates how to implement the RootLogger interface with a dummy logger. This example shows the basic structure required for a logger class, including methods for logging at various levels and managing scopes. It does not perform actual logging. ```typescript import { RootLogger } from "@workleap/logging"; class DummyLogger implements RootLogger { getName() { return DummyLogger.name; } withText() { return this; } withError() { return this; } withObject() { return this; } debug() {} information() {} warning() {} error() {} critical() {} startScope() { return new DummyLoggerScope(); } } // Assuming DummyLoggerScope is defined elsewhere and implements LoggerScope class DummyLoggerScope { // ... scope implementation } ``` -------------------------------- ### Filter log entries by minimum severity level Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Configures the `BrowserConsoleLogger` to only process log entries at or above a specified severity level (e.g., `LogLevel.error`). Entries with lower severity are ignored. ```typescript import { BrowserConsoleLogger, LogLevel } from "@workleap/logging"; const logger = new BrowserConsoleLogger({ logLevel: LogLevel.error }); // Will be ignored because "debug" is lower than the "error" severity. logger.debug("Hello world!"); ``` -------------------------------- ### Log styled text segments Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/getting-started.md Demonstrates how to apply styling to individual text segments within a log entry using the BrowserConsoleLogger. If the logger does not support styling, the text is logged without it. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger .withText("Build completed", { style: { color: "green", fontWeight: "bold" } }) .withText("in") .withText("250ms", { style: { color: "gray" } }) .information(); ``` -------------------------------- ### Use and manage logging scopes Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Demonstrates the use of logging scopes to group related log entries. Scopes can be started with a label, and log messages within the scope are buffered until the scope is ended. Scopes can also be dismissed to prevent output. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); const scope = logger.startScope("Module 1 registration"); scope.debug("Registering routes..."); scope .withText("Routes registered!") .withObject([{ path: "/foo", label: "Foo" }]) .debug(); scope.debug("Fetching data..."); scope .withText("Data fetching failed") .withError(new Error("The specified API route doesn't exist.")) .error(); scope.debug("Registration failed!", { style: { backgroundColor: "red", color: "white", fontWeight: "bold" } }); // Once the scope is ended, the log entries will be outputted to the console. scope.end(); ``` ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); const scope = logger.startScope("Module 1 registration"); scope.debug("Registering routes..."); scope .withText("Routes registered!") .withObject([{ path: "/foo", label: "Foo" }]) .debug(); scope.debug("Fetching data..."); // Will not output any log entries to the console. scope.end({ dismiss: true }); ``` -------------------------------- ### Dummy LoggerScope Implementation in TypeScript Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/LoggerScope.md This TypeScript code provides a dummy implementation of the LoggerScope interface. It serves as a placeholder or a basic example for how to implement the interface, returning `this` for methods that chain and having no-op implementations for logging methods. ```typescript import { LoggerScope } from "@workleap/logging"; class DummyLoggerScope implements LoggerScope { withText() { return this; } withError() { return this; } withObject() { return this; } debug() {} information() {} warning() {} error() {} critical() {} end() {} } ``` -------------------------------- ### Initialize CompositeLogger with multiple loggers Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Demonstrates how to create a CompositeLogger instance by passing an array of logger instances. This setup allows for concurrent logging to multiple destinations. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); ``` -------------------------------- ### Filter log entries by severity with CompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Configures CompositeLogger with different log levels for its underlying loggers. This example shows how to filter entries based on severity, ensuring only messages at or above a certain level are processed by each logger. ```typescript import { CompositeLogger, ConsoleLogger, LogLevel } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger({ logLevel: LogLevel.error }), new LogRocketLogger({ logLevel: LogLevel.debug }) ]); // Will be ignored because "debug" is lower than the "error" severity. logger.debug("Hello world!"); ``` -------------------------------- ### Style Scope Label on End - TypeScript Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md This snippet illustrates styling a scope label when it is ended using the BrowserConsoleLogger from the Workleap logging library. It imports the logger, starts a scope, logs a message, and then ends the scope with custom label styles for background and text color. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); const scope = logger.startScope("A scope"); scope.information("Hello world!"); scope.end({ labelStyle: { backgroundColor: "purple", color: "white" } }); ``` -------------------------------- ### BrowserConsoleLogger Initialization Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Initializes a new instance of BrowserConsoleLogger. Options can be provided to configure the logger, such as setting the minimum log level. ```APIDOC ## BrowserConsoleLogger Initialization ### Description Initializes a new instance of BrowserConsoleLogger. Options can be provided to configure the logger, such as setting the minimum log level. ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts const logger = new BrowserConsoleLogger(options?: { logLevel? }) ``` ### Response #### Success Response (200) N/A (Constructor returns an instance) #### Response Example ```json { "instance": "BrowserConsoleLogger" } ``` ``` -------------------------------- ### Configure Context7 MCP Server in VS Code (Local) Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/use-with-agents.md Configures the Context7 MCP server for local connection within VS Code. This method uses a command to run the MCP server locally, requiring the command, arguments, and an optional API key. ```json { "mcp": { "servers": { "context7": { "type": "stdio", "command": "npx", "args": [ "-y", "@upstash/context7-mcp", "--api-key", "YOUR_OPTIONAL_API_KEY" ] } } } } ``` -------------------------------- ### Styling Scope Labels Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Allows styling the scope label directly when the scope is created using the `labelStyle` option. ```APIDOC ## Styling Scope Labels ### Description Allows styling the scope label directly when the scope is created using the `labelStyle` option. This applies CSS styles to the scope's label text. ### Method `startScope(label: string, options?: { labelStyle?: object })` ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts const logger = new BrowserConsoleLogger(); const scope = logger.startScope("A scope", { labelStyle: { backgroundColor: "purple", color: "white" } }); scope.information("Hello world!"); scope.end(); ``` ### Response #### Success Response (200) N/A (Method configures scope creation) #### Response Example ```json { "status": "scope created with styled label" } ``` ``` -------------------------------- ### Building Complex Log Entries Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Allows chaining multiple `withText`, `withObject`, and `withError` calls to construct a detailed log entry before calling a logging method. ```APIDOC ## Building Complex Log Entries ### Description Allows chaining multiple `withText`, `withObject`, and `withError` calls to construct a detailed log entry before calling a logging method. All segments are processed and outputted to the console when a logging method (e.g., `debug`, `information`) is called. ### Method - `withText(text: string, options?: { style?: object })` - `withObject(data: object)` - `withError(error: Error)` ### Endpoint N/A (Instance Methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts logger .withText("Processing segment") .withObject({ id: 1 }) .withText("failed with error") .withError(new Error("The error")) .debug(); ``` ### Response #### Success Response (200) N/A (Methods perform logging actions) #### Response Example ```json { "status": "logged with complex entry" } ``` ``` -------------------------------- ### Instantiate BrowserConsoleLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Creates a new instance of BrowserConsoleLogger. An optional options object can be provided to configure the logger, such as setting a minimum logLevel for messages to be processed. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(options?: { logLevel? }); ``` -------------------------------- ### Logging Methods Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Provides methods for logging messages at different severity levels: debug, information, warning, error, and critical. ```APIDOC ## Logging Methods ### Description Provides methods for logging messages at different severity levels: debug, information, warning, error, and critical. ### Method - `debug(message: string)` - `information(message: string)` - `warning(message: string)` - `error(message: string)` - `critical(message: string)` ### Endpoint N/A (Instance Methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts logger.debug("Hello world!"); logger.information("This is an informational message."); logger.warning("This is a warning."); logger.error("An error occurred."); logger.critical("A critical failure."); ``` ### Response #### Success Response (200) N/A (Methods perform logging actions) #### Response Example ```json { "status": "logged" } ``` ``` -------------------------------- ### Add Context7 MCP Server to Claude Code (Local) Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/use-with-agents.md Adds the Context7 MCP server for local connection to Claude Code. This command configures Claude Code to run the Context7 MCP server locally using pnpmx, specifying the package and an optional API key. ```bash claude mcp add context7 -- pnpmx -y @upstash/context7-mcp --api-key YOUR_OPTIONAL_API_KEY ``` -------------------------------- ### Styling Log Entries Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Enables applying custom styles to text segments within a log entry using the `style` option. ```APIDOC ## Styling Log Entries ### Description Enables applying custom styles to text segments within a log entry using the `style` option. Styles are applied using standard CSS properties. ### Method `withText(text: string, options?: { style?: object })` ### Endpoint N/A (Instance Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts logger .withText("Hello", { style: { backgroundColor: "green", color: "white", } }) .withText("World", { style: { backgroundColor: "blue", color: "white" } }) .information(); ``` ### Response #### Success Response (200) N/A (Methods perform logging actions) #### Response Example ```json { "status": "logged with styled text" } ``` ``` -------------------------------- ### Style scope label on creation Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Allows styling of the scope's label directly when the scope is created. This is achieved by passing a labelStyle object with CSS properties to the startScope method. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); const scope = logger.startScope("A scope", { labelStyle: { backgroundColor: "purple", color: "white" } }); scope.information("Hello world!"); scope.end(); ``` -------------------------------- ### Configure Context7 MCP Server in VS Code (Remote) Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/use-with-agents.md Configures the Context7 MCP server for remote connection within VS Code. This involves adding the server details to the VS Code MCP configuration file, specifying the server type, URL, and optional API key. ```json { "mcp": { "servers": { "context7": { "type": "http", "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "YOUR_OPTIONAL_API_KEY" } } } } } ``` -------------------------------- ### Logging Scopes Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Manages logging scopes using `startScope` and `end` methods. Scopes group related log entries, which are only outputted to the console after the scope is ended. ```APIDOC ## Logging Scopes ### Description Manages logging scopes using `startScope` and `end` methods. Scopes group related log entries, which are only outputted to the console after the scope is ended. Scopes can also be dismissed to prevent output. ### Method - `startScope(label: string, options?: { labelStyle?: object })` - `end(options?: { dismiss?: boolean })` ### Endpoint N/A (Instance Methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts const logger = new BrowserConsoleLogger(); const scope = logger.startScope("Module 1 registration"); scope.debug("Registering routes..."); scope .withText("Routes registered!") .withObject([{ path: "/foo", label: "Foo" }]) .debug(); // To dismiss the scope and prevent output: // scope.end({ dismiss: true }); scope.end(); // Outputs all logs within this scope. ``` ### Response #### Success Response (200) N/A (Methods manage scope lifecycle) #### Response Example ```json { "status": "scope ended" } ``` ``` -------------------------------- ### Build and log complex entries Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Constructs a log entry by chaining multiple segments, including styled text, objects, and errors. The final log method (e.g., .debug()) triggers the output of the combined entry to the console. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger .withText("Processing segment") .withObject({ id: 1 }) .withText("failed with error") .withError(new Error("The error")) .debug(); ``` -------------------------------- ### Log messages with BrowserConsoleLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Demonstrates how to log messages at different severity levels (debug, information, warning, error, critical) using the BrowserConsoleLogger. Each method corresponds to a specific log level. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger.debug("Hello world!"); ``` ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger.information("Hello world!"); ``` ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger.warning("Hello world!"); ``` ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger.error("Hello world!"); ``` ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger.critical("Hello world!"); ``` -------------------------------- ### Style log entry segments Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Applies custom styling to individual text segments within a log entry. Styling options, such as background color and text color, are passed as an object to the withText method. ```typescript import { BrowserConsoleLogger } from "@workleap/logging"; const logger = new BrowserConsoleLogger(); logger .withText("Hello", { style: { backgroundColor: "green", color: "white", } }) .withText("World", { style: { backgroundColor: "blue", color: "white" } }) .information(); ``` -------------------------------- ### Build complex log entries with CompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Demonstrates chaining multiple methods like `withText` and `withObject` to construct a detailed log entry before calling a logging method. This allows for rich log data including text segments, objects, and errors. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); logger .withText("Processing segment") .withObject({ id: 1 }) .withText("failed with error") .withError(new Error("The error")) .debug(); ``` -------------------------------- ### Style log entries using CompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Shows how to apply styles to text segments within a log entry using `withText` and a style object. The CompositeLogger forwards these styles to underlying loggers that support them. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); logger .withText("Hello", { style: { backgroundColor: "green", color: "white", } }) .withText("World", { style: { backgroundColor: "blue", color: "white" } }) .information(); ``` -------------------------------- ### Add Context7 MCP Server to Claude Code (Remote) Source: https://github.com/workleap/wl-logging/blob/main/docs/introduction/use-with-agents.md Adds the Context7 MCP server for remote connection to Claude Code. This command-line instruction configures Claude Code to use the specified HTTP endpoint for the Context7 MCP server, including an optional API key. ```bash claude mcp add --header "CONTEXT7_API_KEY: YOUR_OPTIONAL_API_KEY" --transport http context7 https://mcp.context7.com/mcp ``` -------------------------------- ### Style Scope Label at Creation with Workleap Logging Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Illustrates styling a scope's label directly when it is created. This allows for setting initial visual styles for the scope. It uses CompositeLogger and ConsoleLogger. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); const scope = logger.startScope("A scope", { labelStyle: { backgroundColor: "purple", color: "white" } }); scope.information("Hello world!"); scope.end(); ``` -------------------------------- ### Use Logging Scope with Workleap Logging Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Demonstrates how to create a logging scope, add log messages with text and objects, and end the scope. It utilizes CompositeLogger and ConsoleLogger, with an optional LogRocketLogger. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); const scope = logger.startScope("Module 1 registration"); scope.debug("Registering routes..."); scope .withText("Routes registered!") .withObject([{ path: "/foo", label: "Foo" }]) .debug(); scope.debug("Fetching data..."); scope .withText("Data fetching failed") .withError(new Error("The specified API route doesn't exist.")) .error(); scope.debug("Registration failed!", { style: { backgroundColor: "red", color: "white", fontWeight: "bold" } }); // Once the scope is ended, the log entries will be outputted to the console. scope.end(); ``` -------------------------------- ### Log a warning entry using CompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Demonstrates how to log a warning message. The CompositeLogger ensures the warning is dispatched to all its configured loggers. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); logger.warning("Hello world!"); ``` -------------------------------- ### Log an information entry using CompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Illustrates logging an informational message with CompositeLogger. This message will be processed by all attached loggers. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); logger.information("Hello world!"); ``` -------------------------------- ### Create CompositeLogger Instance (TypeScript) Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/createCompositeLogger.md Creates a CompositeLogger instance, optionally enabling verbose logging and providing an array of logger implementations. If no loggers are provided, a ConsoleLogger is used by default. ```typescript import { ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = createCompositeLogger(false, [new ConsoleLogger(), new LogRocketLogger()]); ``` -------------------------------- ### createCompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/createCompositeLogger.md A factory function to create a CompositeLogger instance from Workleap libraries standard logging API. ```APIDOC ## createCompositeLogger ### Description A factory function to create a `CompositeLogger` instance from Workleap libraries standard logging API. ### Method Factory Function (Conceptual) ### Endpoint N/A (This is a function call, not a REST endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **verbose** (boolean) - Required - Indicates whether or not debug information should be logged. - **loggers** (Array) - Optional - Loggers to create the `CompositeLogger` with. If no loggers are provided, the `CompositeLogger` instance will be created with a `ConsoleLogger` instance by default. ### Returns - **CompositeLogger** - A `CompositeLogger` instance. ### Request Example ```ts import { ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = createCompositeLogger(false, [new ConsoleLogger(), new LogRocketLogger()]); ``` ### Response #### Success Response (200) N/A (This is a function call, not a REST endpoint) #### Response Example ```json { "instance": "CompositeLogger" } ``` ``` -------------------------------- ### Log a critical entry using CompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Illustrates logging a critical event. The CompositeLogger ensures this high-severity message reaches all configured loggers. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); logger.critical("Hello world!"); ``` -------------------------------- ### Log a debug entry using CompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Shows how to log a debug message using the CompositeLogger. The message will be sent to all configured underlying loggers. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); logger.debug("Hello world!"); ``` -------------------------------- ### Filtering Log Entries by LogLevel Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/BrowserConsoleLogger.md Configures the logger to only process messages with a severity level greater than or equal to the specified `logLevel`. ```APIDOC ## Filtering Log Entries by LogLevel ### Description Configures the logger to only process messages with a severity level greater than or equal to the specified `logLevel`. Messages with a lower severity than the configured level will be ignored. ### Method Constructor option `logLevel` ### Endpoint N/A (Class Constructor Option) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```ts import { BrowserConsoleLogger, LogLevel } from "@workleap/logging"; const logger = new BrowserConsoleLogger({ logLevel: LogLevel.error }); // This debug message will be ignored. logger.debug("Hello world!"); ``` ### Response #### Success Response (200) N/A (Configuration affects logger behavior) #### Response Example ```json { "configuration": "logLevel set to error" } ``` ``` -------------------------------- ### Style Scope Label at End with Workleap Logging Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Demonstrates styling a scope's label when the scope is ended. This is useful for dynamically styling the label based on the outcome of an operation. It uses CompositeLogger and ConsoleLogger. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger(); ]); const scope = logger.startScope("A scope"); scope.information("Hello world!"); scope.end({ labelStyle: { backgroundColor: "purple", color: "white" } }); ``` -------------------------------- ### Log an error entry using CompositeLogger Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Shows how to log an error message. The CompositeLogger forwards the error to all underlying loggers for processing and storage. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); logger.error("Hello world!"); ``` -------------------------------- ### Dismiss Logging Scope with Workleap Logging Source: https://github.com/workleap/wl-logging/blob/main/docs/reference/CompositeLogger.md Shows how to dismiss a logging scope, preventing its log entries from being outputted. This is useful for conditionally logging information. It uses CompositeLogger and ConsoleLogger. ```typescript import { CompositeLogger, ConsoleLogger } from "@workleap/logging"; import { LogRocketLogger } from "@workleap/telemetry"; // or from "@workleap/logrocket"; const logger = new CompositeLogger([ new ConsoleLogger(), new LogRocketLogger() ]); const scope = logger.startScope("Module 1 registration"); scope.debug("Registering routes..."); scope .withText("Routes registered!") .withObject([{ path: "/foo", label: "Foo" }]) .debug(); scope.debug("Fetching data..."); // Will not output any log entries to the console. scope.end({ dismiss: true }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.