Logestic
An advanced and customisable logging library for ElysiaJS.
Table of Contents
Installation
Add the package to your Elysia Project.
bun add logestic
Note: You must have elysia@1.0
installed in your project.
Usage
There are two ways to add logging to your Elysia application.
Preset request logging
Currently, there are these presets available to use.
import { Elysia } from 'elysia';
import { Logestic } from 'logestic';
const app = new Elysia()
.use(Logestic.preset('common'))
.get('/', () => "Hello from server")
.listen(5566);
Output:
Custom request logging
If you don't like any of presets, you can configure Logestic to log your requests in your way.
- Create a
Logestic
instance, optionally where you wish to log. - Call
use
to tell Logestic
the information you wish to use. - Finally, create an
Elysia
instance on custom
with the formatting function.
import { Logestic } from 'logestic';
export default new Logestic(Bun.file('request.log'))
.use(['method', 'path', 'time', 'status'])
.format(({ method, path, time, status }) => {
return `[${time}]: ${method} ${path} | ${status}`
});
import myLogger from './logger';
const app = new Elysia()
.use(myLogger)
.get('/', () => "Hello from server")
.listen(5566);
Consider contributing your own preset; check contributing guidelines.
Contributing Guidelines
See CONTRIBUTING.md
License
MIT
Authors