https://github.com/0xrasla/logify
An easy to use logger for elysia js.
https://github.com/0xrasla/logify
bun bunjs elysiajs logger typescript
Last synced: 3 months ago
JSON representation
An easy to use logger for elysia js.
- Host: GitHub
- URL: https://github.com/0xrasla/logify
- Owner: 0xrasla
- License: mit
- Created: 2024-12-03T08:15:48.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-09-20T14:59:41.000Z (4 months ago)
- Last Synced: 2025-09-21T04:44:59.458Z (4 months ago)
- Topics: bun, bunjs, elysiajs, logger, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@rasla/logify
- Size: 168 KB
- Stars: 18
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Logify
[](https://opensource.org/licenses/MIT)
A beautiful, fast, and type-safe logging middleware for Node.js web applications. Get instant insights into your HTTP requests with colorized console output and structured file logging.
## 📦 Packages
This monorepo contains the following packages:
- [@rasla/logify](./packages/elysia-js) - Logging middleware for Elysia.js
- [@rasla/express-logify](./packages/express) - Logging middleware for Express.js
## ✨ Features
- 🎨 Beautiful console output with color-coded log levels
- ⚡ Zero-config with smart defaults
- 📊 Request duration and status code tracking
- 🌐 IP address logging with proxy support
- 📝 Structured logging with TypeScript support
- 🎯 Path-based request filtering
- 🔄 Automatic log directory creation
- 🎛️ Fully customizable log formats
- 🌍 Global logger instance for application-wide logging
- 📝 Convenient logging functions: debug(), info(), warn(), and error()
## 📥 Installation
Choose the package that matches your framework:
### For Elysia.js
```bash
bun add @rasla/logify
```
### For Express.js
```bash
npm install @rasla/express-logify
# or
yarn add @rasla/express-logify
# or
pnpm add @rasla/express-logify
```
## 🚀 Quick Start
### Elysia.js
```typescript
import { Elysia } from "elysia";
import { logger } from "@rasla/logify";
const app = new Elysia()
.use(logger())
.get("/", () => "Hello World!")
.listen(3000);
```
### Express.js
```typescript
import express from "express";
import { logger } from "@rasla/express-logify";
const app = express();
app.use(logger());
app.get("/", (req, res) => res.send("Hello World!"));
app.listen(3000);
```
## 🌍 Global Logger
Both packages now include a global logger that can be accessed from anywhere in your application:
````typescript
// Elysia.js
import {
initializeLogger,
debug,
info,
warn,
error
} from "@rasla/logify";
// Express.js
import {
initializeLogger,
debug,
info,
warn,
error
} from "@rasla/express-logify";
// Configure once at startup
initializeLogger({
level: "debug",
file: true,
filePath: "./logs/app.log"
});
// Use anywhere in your code
debug("This is a debug message");
info("This is an info message");
warn("This is a warning message");
error("This is an error message");
| `{statusCode}` | HTTP status | `200`, `404` |
| `{duration}` | Request time | `123ms` |
| `{ip}` | Client IP | `127.0.0.1` |
````
## 🎯 Examples
Check out the examples in each package:
- [Elysia.js Examples](./packages/elysia-js/examples)
- [Express.js Examples](./packages/express/examples)
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## 🎨 Configuration
Both packages support the same configuration options:
```typescript
{
// Console logging (default: true)
console: true,
// File logging (default: false)
file: true,
filePath: './logs/app.log',
// Log level (default: "info")
level: 'debug', // "debug" | "info" | "warn" | "error"
// Skip certain paths
skip: ['/health', '/metrics'],
// Include IP address (default: false)
includeIp: true,
// Custom format (see Format Tokens below)
format: '[{timestamp}] {level} [{method}] {path} - {statusCode} {duration}ms{ip}',
}
````
## 📝 Format Tokens
Customize your log format using these tokens:
| Token | Description | Example |
| -------------- | ------------- | -------------------------- |
| `{timestamp}` | ISO timestamp | `2024-12-03T17:48:54.721Z` |
| `{level}` | Log level | `INFO`, `ERROR` |
| `{method}` | HTTP method | `GET`, `POST` |
| `{path}` | Request path | `/api/users` |
| `{statusCode}` | HTTP status | `200`, `404` |
| `{duration}` | Request time | `123ms` |
| `{ip}` | Client IP | `127.0.0.1` |
## 🎯 Examples
Check out the examples in each package:
- [Elysia.js Examples](./packages/elysia-js/examples)
- [Express.js Examples](./packages/express/examples)
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## 📄 License
MIT License - Created by [0xRasla](https://github.com/0xRasla)