CKN Technology Core · Log Utility

CKN Technology Core
Log Extensions

This page documents the Log class provided by @ckn-technology/core, focusing on how to construct log instances and use the info and error methods with consistent, timestamped outputs across your applications.

Import

To load and enable the custom Log extensions described on this page, import the core package once at the entry point of your application (or any module that runs during startup).

import "@ckn-technology/core";

Once imported, the Log utilities are available globally for all code that uses the Log class.

Constructor

constructor(...prefixs)

Description
Creates a new Log instance with one or more prefixes. These prefixes will be printed before all log messages from this instance, making it easy to trace logs by module, context, or subsystem.

Signature

constructor(...prefixs: string[])

Example

const log = new Log("[APP]", "[USER]");

Methods

info(...msg)

Description
Logs an informational message to console.log with:

  • Timestamp using dateTimeDataFormat()
  • All configured prefixes for this Log instance
  • All message parts supplied to the method

Signature

info(...msg: string[]): void

Example

const log = new Log("[SERVER]", "[INFO]");
log.info("Server started", "port:", "8080");

// Output example:
// 2025-01-07 13:45:30 [SERVER] [INFO] Server started port: 8080

error(...msg)

Description
Logs an error message using console.error with:

  • Timestamp from dateTimeDataFormat()
  • All prefixes configured for this Log instance
  • All message parts that describe the error

Signature

error(...msg: string[]): void

Example

const log = new Log("[API]", "[ERROR]");
log.error("Failed to fetch data", "Code:", "500");

// Output example:
// 2025-01-07 13:45:30 [API] [ERROR] Failed to fetch data Code: 500