@ultra8k/qonos
v0.3.0
Published
A basic Typescript console logger
Downloads
12
Maintainers
Readme
QonoS
Qonos, which is Kilngon for Log, is a basic Typescript console logger with simple options for level, color, trace and timestamp.
Install
npm i @ultra8k/qonos -D
yarn add @ultra8k/qonos -D
pnpm add @ultra8k/qonos -D
Options
| Name | Type | Default | Description | | ---------- | ------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | level | String | "debug" | Determines the minimum level that will execute.Choose between "debug", "info", "warn", "error" | | colorize | Boolean | true | If true; use customized console level colors.If false; use the default console colors | | colors | Object | { debug: "#A5B4FC", info: "#67E8F9", warn: "#FDE047", error: "#FCA5A5",} | Custom level colors | | trace | Boolean | true | Show file name and line number | | timestamp | Boolean | true | Show timestamp of log | | stampFirst | Boolean | true | true will display log message as [timestamp | trace | message];false will display the log message as [trace | timestamp | message] |
Usage
ES Module
import { Logger } from "@ultra8k/qonos";
const options: LogOptions = {
level: "debug",
colorize: true,
colors: {
debug: "#A5B4FC",
info: "#67E8F9",
warn: "#FDE047",
error: "#FCA5A5",
},
trace: true,
timestamp: true,
stampFirst: true,
};
export const logger = new Logger(options);
// use log levels to display messages
logger.debug("log a debug message");
logger.info("log an info message");
logger.warn("log a warn message");
logger.error("log an error message");
UMD Module
<script src="@ultra8k/qonos/dist/qonos.umd.js"></script>
<script>
const options = {
level: "debug",
colorize: true,
colors: {
debug: "#A5B4FC",
info: "#67E8F9",
warn: "#FDE047",
error: "#FCA5A5",
},
trace: true,
timestamp: true,
stampFirst: true,
};
const logger = new qonos.Logger(options);
logger.debug("this", "works!");
logger.info("so", "does", "this");
</script>