losi-logger
v1.0.0
Published
A clean and minimal TypeScript logger
Maintainers
Readme
🔥 losi-logger
A lightweight, clean, and TypeScript-ready logger for both Node.js and React (browser) apps. Color-coded logs, timestamped output, adjustable log levels — simple, elegant, and developer-friendly.
✨ Features
✅ Written in TypeScript
✅ Works in Node.js and React/browser
✅ Color-coded & timestamped logs
✅ Adjustable log level (debug, info, warn, error)
✅ Lightweight — only 1 dependency (Chalk)
✅ Simple, clean API
📦 Installation
From npm
npm install losi-logger🧩 Quick Start
🔹 Import the Logger
You can import it as a class and create your own logger instance.
import { Logger } from "losi-logger";
const logger = new Logger({
level: "debug",
showTimestamp: true,
});⚙️ Configuration Options
| Option | Type | Default | Description | | | |
| --------------- | --------- | ------- | -------------------------------------------------- | -------- | -------- | --------------------------------------------------------- |
| level | "debug" | "info" | "warn" | "error" | "info" | Minimum log level to show. Lower levels are filtered out. |
| showTimestamp | boolean | true | Whether to display timestamps before log messages. | | | |
Example:
const logger = new Logger({
level: "warn",
showTimestamp: false,
});Logs below “warn” (like info or debug) will not appear.
🚀 Example Usage
🟦 Node.js Example
index.js
import { Logger } from "losi-logger";
const logger = new Logger({
level: "debug",
showTimestamp: true,
});
logger.info("Server started successfully!");
logger.warn("Low memory warning...");
logger.error("Something went wrong!");
logger.debug("Debugging details here...");🧾 Terminal Output (with colors):
[2025-10-22T08:12:31.342Z] INFO: Server started successfully!
[2025-10-22T08:12:31.345Z] WARN: Low memory warning...
[2025-10-22T08:12:35.100Z] ERROR: Something went wrong!
[2025-10-22T08:12:35.102Z] DEBUG: Debugging details here...🟨 React JSX Example
Works perfectly with Create React App, Vite, or Next.js.
src/logger.js
import { Logger } from "losi-logger";
const logger = new Logger({
level: "debug",
showTimestamp: true,
});
export default logger;src/App.jsx
import React, { useEffect } from "react";
import logger from "./logger";
function App() {
useEffect(() => {
logger.info("App mounted successfully 🚀");
logger.debug("Component initialized");
}, []);
const handleClick = () => {
logger.warn("Button clicked!");
logger.error("Example error message 😅");
};
return (
<div style={{ padding: 20 }}>
<h1>losi Logger Demo</h1>
<button onClick={handleClick}>Click Me</button>
</div>
);
}
export default App;🧾 Browser Console Output:
[2025-10-22T08:12:31.342Z] INFO: App mounted successfully 🚀
[2025-10-22T08:12:31.345Z] DEBUG: Component initialized
[2025-10-22T08:12:35.100Z] WARN: Button clicked!
[2025-10-22T08:12:35.102Z] ERROR: Example error message 😅Each log is automatically color-coded using CSS colors in the browser console.
🧠 Log Levels Explained
| Level | Description | Output Color |
| ------- | ------------------------- | ------------ |
| debug | Development-only messages | Magenta |
| info | General information | Blue |
| warn | Non-breaking warnings | Yellow |
| error | Critical issues | Red |
🧱 Dual Environment Support
losi-logger automatically detects where it’s running:
- 🖥 Node.js → Uses Chalk for terminal colors
- 🌐 Browser (React) → Uses
console.logwith CSS color styling
No configuration needed — it just works!
🪄 API Summary
logger.info(message: any)
logger.warn(message: any)
logger.error(message: any)
logger.debug(message: any)Each log automatically includes:
- A timestamp (optional)
- Log level tag
- Colorized output (terminal or browser)
📄 License
MIT © 2025 Made with ❤️ by Losi
🌟 Summary
| Feature | Description | | ------------------- | ------------------------------- | | 🧠 TypeScript | Built for modern JS/TS projects | | 🌈 Colorized logs | Easy to read output | | 🕐 Timestamped | Automatic ISO timestamps | | ⚙️ Configurable | Control verbosity & timestamps | | 🪶 Lightweight | Only Chalk dependency | | 💻 Works everywhere | Node + React/browser compatible |
Enjoy clean logging with 🪶 losi-logger!
