Logger API
createLogger Logging
Creates an independent logger.
Signature
ts
export function createLogger(options: LoggerOptions = {}): Logger;Example
ts
import { createLogger } from "@fast-china/utils";
const result = createLogger({ brand: "Admin", minimumLevel: "warn" });Input
| Input | Type | Required / default | Description |
|---|---|---|---|
options | LoggerOptions | Optional; defaults to {} | Level, prefix, sink, and uni-app App-Plus argument-splitting options. |
Returns
| Value | Type | Description |
|---|---|---|
result | Logger | New instance that does not modify the global console or other loggers. |
configureLogger Logging
Replaces the default logger's entire configuration.
Signature
ts
export function configureLogger(options: LoggerOptions = {}): void;Example
ts
import { configureLogger } from "@fast-china/utils";
configureLogger({ brand: "Admin", minimumLevel: "warn" });Input
| Input | Type | Required / default | Description |
|---|---|---|---|
options | LoggerOptions | Optional; defaults to {} | Level, prefix, sink, and uni-app App-Plus argument-splitting options for the default logger. |
Returns
| Value | Type | Description |
|---|---|---|
result | void | No return value. |
logger.debug / logger.log / logger.warn / logger.error Logging
Writes a scoped log to the current sink at the specified level. All four methods share the same input and void return contract.
Signature
ts
debug(scope: string, ...content: unknown[]): void;
log(scope: string, ...content: unknown[]): void;
warn(scope: string, ...content: unknown[]): void;
error(scope: string, ...content: unknown[]): void;Example
ts
import { logger } from "@fast-china/utils";
logger.debug("startup", "initializing");
logger.log("api", "request completed", { status: 200 });
logger.warn("cache", "entry expired");
logger.error("api", "request failed", new Error("network"));Input
| Input | Type | Required / default | Description |
|---|---|---|---|
scope | string | Required | Nonempty module, component, or business-source name with no surrounding whitespace. |
...content | unknown[] | Optional; multiple arguments allowed | Message and additional values; nonstrings preserve their original types. |
Returns
| Value | Type | Description |
|---|---|---|
result | void | No return value; messages below the minimum level are not written. |
