Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pungrumpy/logixlysia
🦊 Logixlysia is a logger for ElysiaJS
https://github.com/pungrumpy/logixlysia
bun elysia elysiajs log logger logging logixlysia
Last synced: about 21 hours ago
JSON representation
🦊 Logixlysia is a logger for ElysiaJS
- Host: GitHub
- URL: https://github.com/pungrumpy/logixlysia
- Owner: PunGrumpy
- License: mit
- Created: 2023-11-04T15:17:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-22T10:19:19.000Z (8 months ago)
- Last Synced: 2024-05-22T10:37:01.175Z (8 months ago)
- Topics: bun, elysia, elysiajs, log, logger, logging, logixlysia
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/logixlysia
- Size: 3.25 MB
- Stars: 14
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
🦊
Logixlysia
Logixlysia is a logging library for ElysiaJS
## `📩` Installation
```bash
bun add logixlysia
```## `📝` Usage
```ts
import { Elysia } from 'elysia'
import logixlysia from 'logixlysia'const app = new Elysia({
name: 'Logixlysia Example'
}).use(
logixlysia({
config: {
showStartupMessage: true,
startupMessageFormat: 'simple',
timestamp: {
translateTime: 'yyyy-mm-dd HH:MM:ss'
},
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](example) directory.## `📚` Documentation
### Options
| Option | Type | Description | Default |
| ---------------------- | ------------------------ | --------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| `showStartupMessage` | `boolean` | Display the startup message | `true` |
| `startupMessageFormat` | `"banner"` \| `"simple"` | Choose the startup message format | `"banner"` |
| `timestamp` | `object` | Display the timestamp in the logs | `{ translateTime: 'yyyy-mm-dd HH:MM:ss' }` |
| `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](LICENSE).