### Logsets Initialization Source: https://context7.com/zhangfisher/logsets/llms.txt Demonstrates how to initialize a Logsets instance with default settings or custom configurations for colorization and formatting. ```APIDOC ## Logsets Initialization ### Description Initialize a logsets instance with custom configuration options to control colorization, formatting, and logging behavior across your application. ### Method `require('logsets')([options])` ### Parameters #### Query Parameters - **options** (object) - Optional - Configuration object for the logger. - **compact** (boolean) - Optional - Enables compact output mode. - **Array** (object) - Optional - Formatting options for arrays. - **maxItems** (number) - Optional - Maximum number of items to display in an array. - **align** (boolean) - Optional - Enables alignment for array elements. - **Object** (object) - Optional - Formatting options for objects. - **maxItems** (number) - Optional - Maximum number of items to display in an object. - **align** (boolean) - Optional - Enables alignment for object properties. - **compact** (boolean) - Optional - Enables compact output for objects. - **String** (object) - Optional - Formatting options for strings. - **style** (string) - Optional - Default style for strings (e.g., 'yellow'). - **Number** (object) - Optional - Formatting options for numbers. - **style** (string) - Optional - Default style for numbers (e.g., 'cyan'). - **levels** (object) - Optional - Defines logging levels and their associated styles. - **debug** (string) - Optional - Style for DEBUG level. - **info** (string) - Optional - Style for INFO level. - **warn** (string) - Optional - Style for WARN level. - **error** (string) - Optional - Style for ERROR level. - **fatal** (string) - Optional - Style for FATAL level. ### Request Example ```javascript const logsets = require('logsets'); // Use default instance logsets.print("Hello World"); // Create custom instance with specific options const customLogger = logsets({ compact: true, Array: { maxItems: 10 }, Object: { maxItems: 5, align: true }, String: { style: "yellow" }, Number: { style: "cyan" }, levels: { debug: "blue", info: "green", warn: "yellow", error: "red", fatal: "bgRed,white" } }); customLogger.print({ name: "tom", age: 30, roles: ["admin", "user"] }); ``` ### Response #### Success Response (200) - **customLogger** (object) - A configured Logsets instance. #### Response Example (Output depends on the configuration and data passed to `print`) ``` -------------------------------- ### Initialize Logsets Instance with Custom Options Source: https://context7.com/zhangfisher/logsets/llms.txt Demonstrates how to initialize a logsets instance with custom configuration. This allows control over colorization, formatting, and logging behavior. Options can specify array/object limits, alignment, string/number styles, and logging level colors. ```javascript const logsets = require('logsets'); // Use default instance logsets.print("Hello World"); // Create custom instance with specific options const customLogger = logsets({ compact: true, Array: { maxItems: 10 }, Object: { maxItems: 5, align: true }, String: { style: "yellow" }, Number: { style: "cyan" }, levels: { debug: "blue", info: "green", warn: "yellow", error: "red", fatal: "bgRed,white" } }); customLogger.print({ name: "tom", age: 30, roles: ["admin", "user"] }); ``` -------------------------------- ### Structured Object Formatting with format() Source: https://context7.com/zhangfisher/logsets/llms.txt Demonstrates how to display objects and arrays with indentation, alignment, and intelligent truncation using the format() function. Supports configuration for array/object item limits and compact mode for dense output. ```javascript const logsets = require('logsets'); // Format complex nested objects logsets.format({ values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], users: { tom: { name: "tom", age: 21, sex: true }, jack: { name: "jack", age: 22, sex: false } }, address: { company: "Beijing", family: "Fujian Province" } }, { Array: { maxItems: 5 }, Object: { maxItems: 5 }, title: "User Data: " }); // Compact mode for dense output logsets.config({ Object: { maxItems: 5, compact: true } }) .format({ number: 100, bool: true, nil: null, empty: undefined, error: new Error("File does not exist") }); ``` -------------------------------- ### Template String Interpolation with log() for Output Source: https://context7.com/zhangfisher/logsets/llms.txt Shows how to output colorized template strings with variable interpolation using logsets. Supports positional or named parameters, with optional color specification per variable and inline color definitions. ```javascript const logsets = require('logsets'); // Positional parameters logsets.log("My name is {}, age is {}", "Alice", 25); // Named parameters logsets.log("{a} + {b} = {c}", { a: 1, b: 2, c: 3 }); // Custom colors for specific variables logsets.log("指定颜色{#red a}+{#bgGreen b}={c}", { a: 100, b: 200, c: 300 }); // Inline color specification logsets.log("Welcome to {#red VoerkaI18n}"); logsets.log("{#blue Voerkai18n}是一个非常不错的{#red,dim 多语言}解决方案!"); ``` -------------------------------- ### Generate Headers and Organize Output with logsets.header() / logsets.h() Source: https://context7.com/zhangfisher/logsets/llms.txt Display prominent section headers with template variable support for organizing console output into logical sections. Supports simple string headers, headers with template interpolation, and a shorthand alias 'h()'. Dependencies include the 'logsets' library. ```javascript const logsets = require('logsets'); // Simple header logsets.header("Configuration Settings"); // Header with template interpolation logsets.header("Processing {} files", 42); logsets.h("User: {name}, Role: {role}", { name: "admin", role: "superuser" }); // Shorthand alias logsets.h("=== Build Process ==="); ``` -------------------------------- ### Structured Object Formatting with format() Source: https://context7.com/zhangfisher/logsets/llms.txt Displays objects and arrays with indentation, alignment, and intelligent truncation for large data structures. ```APIDOC ## Structured Object Formatting with format() ### Description Display objects and arrays with indentation, alignment, and intelligent truncation for large data structures. ### Method `logsets.format(data, [options])` ### Parameters #### Path Parameters - **data** (object | array) - Required - The data structure (object or array) to format. - **options** (object) - Optional - Formatting options. - **Array** (object) - Optional - Formatting options for arrays. - **maxItems** (number) - Optional - Maximum number of items to display in an array. - **Object** (object) - Optional - Formatting options for objects. - **maxItems** (number) - Optional - Maximum number of items to display in an object. - **compact** (boolean) - Optional - Enables compact output for objects. - **title** (string) - Optional - A title to prepend to the formatted output. ### Request Example ```javascript const logsets = require('logsets'); // Format complex nested objects logsets.format({ values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], users: { tom: { name: "tom", age: 21, sex: true }, jack: { name: "jack", age: 22, sex: false } }, address: { company: "Beijing", family: "Fujian Province" } }, { Array: { maxItems: 5 }, Object: { maxItems: 5 }, title: "User Data: " }); // Compact mode for dense output logsets.config({ Object: { maxItems: 5, compact: true } }) .format({ number: 100, bool: true, nil: null, empty: undefined, error: new Error("File does not exist") }); ``` ### Response #### Success Response (200) Prints the formatted object or array to the console. #### Response Example (Output is a structured, indented, and potentially truncated representation of the input data in the terminal) ``` -------------------------------- ### Type-Based Colorization with print() Function Source: https://context7.com/zhangfisher/logsets/llms.txt Illustrates automatic colorization of output based on JavaScript data types using the print() function. Supports primitives, objects, arrays, functions, errors, and dates. Also shows how to control output formatting like overwriting lines or appending text. ```javascript const logsets = require('logsets'); // Print multiple values with automatic colorization logsets.print("String", true, 100, null, undefined); logsets.print([1, 2, 3], { name: "tom", age: 100 }); logsets.print(/^colored$/g, new Date(), new Error("Value Error")); logsets.print(class User{}, () => "hello", async function fetchData() {}); // Control output formatting logsets.print("Processing", 50, "%", { end: "\r" }); // Overwrite line logsets.print("Download complete", { end: "\n", append: " | " }); ``` -------------------------------- ### Template String Interpolation with log() Source: https://context7.com/zhangfisher/logsets/llms.txt Outputs colorized template strings with variable interpolation using positional or named parameters, allowing for optional color specification per variable. ```APIDOC ## Template String Interpolation with log() ### Description Output colorized template strings with variable interpolation using positional or named parameters, with optional color specification per variable. ### Method `logsets.log(template, ...args)` ### Parameters #### Path Parameters - **template** (string) - Required - The template string containing placeholders. - **args** (any) - Required - Positional arguments or a single object for named arguments. ### Query Parameters - **#color** (string) - Optional - Inline color specification for placeholders (e.g., `#red`, `#bgGreen`, `#red,dim`). ### Request Example ```javascript const logsets = require('logsets'); // Positional parameters logsets.log("My name is {}, age is {}", "Alice", 25); // Named parameters logsets.log("{a} + {b} = {c}", { a: 1, b: 2, c: 3 }); // Custom colors for specific variables logsets.log("指定颜色{#red a}+{#bgGreen b}={c}", { a: 100, b: 200, c: 300 }); // Inline color specification logsets.log("Welcome to {#red VoerkaI18n}"); logsets.log("{#blue Voerkai18n}是一个非常不错的{#red,dim 多语言}解决方案!"); ``` ### Response #### Success Response (200) Prints the formatted and colorized string to the console. #### Response Example (Output is a colorized string in the terminal based on the template and provided arguments) ``` -------------------------------- ### Configure Logger Behavior with logsets.config() Source: https://context7.com/zhangfisher/logsets/llms.txt Dynamically update logger configuration to change colorization, data type formatting, and logging level styles. This function can update global settings, apply temporary chained configurations, or create isolated logger instances with specific settings. Dependencies include the 'logsets' library. ```javascript const logsets = require('logsets'); // Update global configuration logsets.config({ String: "yellow", Number: { style: "cyan", format: (v) => `${v}` }, Array: { maxItems: 20 }, Object: { maxItems: 10, align: true, compact: false }, levels: { memo: "red", debug: "blue", info: "green", warn: "yellow", error: "red", fatal: "bgRed,white" } }); logsets.print({ name: "Alice", values: [1, 2, 3, 4, 5] }); // Chained configuration for temporary changes logsets.config({ Object: { maxItems: 3, compact: true } }) .format({ a: 1, b: 2, c: 3, d: 4, e: 5 }); // Create isolated instance with specific config const customLogger = logsets({ compact: true, Boolean: { style: "magenta" }, Null: { style: "darkGray", format: () => "NULL" } }); ``` -------------------------------- ### Type-Based Colorization with print() Source: https://context7.com/zhangfisher/logsets/llms.txt Automatically colorizes output based on JavaScript data types including primitives, objects, arrays, functions, errors, and dates. ```APIDOC ## Type-Based Colorization with print() ### Description Automatically colorize output based on JavaScript data types including primitives, objects, arrays, functions, errors, and dates. ### Method `logsets.print(...args)` ### Parameters #### Path Parameters - **args** (any) - Required - One or more values to be printed with automatic colorization and formatting. ### Query Parameters - **end** (string) - Optional - String appended after the output (default is '\n'). - **append** (string) - Optional - String appended to the end of the line before the `end` character. ### Request Example ```javascript const logsets = require('logsets'); // Print multiple values with automatic colorization logsets.print("String", true, 100, null, undefined); logsets.print([1, 2, 3], { name: "tom", age: 100 }); logsets.print(/^colored$/g, new Date(), new Error("Value Error")); logsets.print(class User{}, () => "hello", async function fetchData() {}); // Control output formatting logsets.print("Processing", 50, "%", { end: "\r" }); // Overwrite line logsets.print("Download complete", { end: "\n", append: " | " }); ``` ### Response #### Success Response (200) Prints the colorized and formatted output to the console. #### Response Example (Output is formatted text in the terminal, with colors automatically applied based on data types) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.