Skip to content

PunGrumpy/logixlysia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0e4a9b7 · Jul 24, 2024
Jul 13, 2024
Jul 24, 2024
May 25, 2024
Jul 24, 2024
Jul 24, 2024
Jul 24, 2024
May 25, 2024
Nov 4, 2023
May 25, 2024
Jun 6, 2024
Nov 22, 2023
Jul 24, 2024
Nov 5, 2023
Jul 24, 2024
Jul 24, 2024
May 21, 2024
Jul 11, 2024
Jul 24, 2024
Nov 4, 2023

Repository files navigation

🦊 Logixlysia

Logixlysia is a logging library for ElysiaJS Screenshot of Logixlysia

📩 Installation

bun add logixlysia

📝 Usage

import { Elysia } from 'elysia'
import logixlysia from 'logixlysia'

const app = new Elysia({
  name: 'Logixlysia Example'
}).use(
  logixlysia({
    config: {
      showBanner: true,
      ip: true,
      logFilePath: './logs/example.log',
      customLogFormat:
        '🦊 {now} {level} {duration} {method} {pathname} {status} {message} {ip} {epoch}',
      logFilter: {
        level: ['ERROR', 'WARNING'],
        status: [500, 404],
        method: 'GET'
      }
    }
  })
)

app.listen(3000)

Note

You can discover more about example in the example directory.

📚 Documentation

Options

Option Type Description Default
showBanner boolean Display the banner on the console true
ip boolean Display the incoming IP address based on the X-Forwarded-For header false
customLogMessage string Custom log message to display 🦊 {now} {level} {duration} {method} {pathname} {status} {message} {ip}
logFilter object Filter the logs based on the level, method, and status null
logFilePath string Path to the log file ./logs/elysia.log

Custom Log Message

Placeholder Description
{now} Current date and time in YYYY-MM-DD HH:mm:ss format
{level} Log level (INFO, WARNING, ERROR)
{duration} Request duration in milliseconds
{method} Request method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
{pathname} Request pathname
{status} Response status code
{message} Custom message
{ip} Incoming IP address
{epoch} Current date and time in Unix epoch format (seconds since January 1, 1970

📄 License

Licensed under the MIT License.