-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from cybercoder-naj/stable-release
Stable Release
- Loading branch information
Showing
16 changed files
with
326 additions
and
223 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
# Contributing to Logestic | ||
|
||
*Coming soon!* | ||
## Reporting Issues | ||
|
||
😥 Feel free to submit an issue when Logestic is not working as you expected. | ||
|
||
## Solving Issues | ||
|
||
1. ❗ All PRs must reference an issue. | ||
2. 🗣 If there is an issue you want to work on, ask on the issue thread if you want to work on it. | ||
3. 🍴 Fork this repository and create a new branch `fix-[number]/[short description]` according to the issue. | ||
4. ✍ Fix the issue. | ||
6. 🎆 Open a PR and wait until a collaborator merges it in. | ||
|
||
## Adding Presets | ||
|
||
1. 🍴 Fork this repository and create a new branch `preset-[name]` with the name of your preset. | ||
2. ✍ Create a new file under [presets/](./src/presets/) and export an Elysia incstance with your Logestic middleware. | ||
3. ➕ Import your file in [index.ts](./src/presets/index.ts) and add the key type to [types](./src/types.ts) | ||
4. 🎆 Open a PR and wait until a collaborator merges it in. Attach a screenshot so we can add to the Wiki. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,27 +10,21 @@ An advanced and customisable logging library for [ElysiaJS](https://elysiajs.com | |
- [Table of Contents](#table-of-contents) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Preset request logging](#preset-request-logging) | ||
- [Custom request logging](#custom-request-logging) | ||
- [Documentation](#documentation) | ||
- [Contributing Guidelines](#contributing-guidelines) | ||
- [License](#license) | ||
- [Authors](#authors) | ||
|
||
## Installation | ||
|
||
Add the package to your Elysia Project. | ||
Add the package to your Elysia Project via [bun](https://bun.sh). | ||
```bash | ||
bun add logestic | ||
``` | ||
**Note**: You must have `[email protected]` installed in your project. | ||
|
||
## Usage | ||
|
||
There are two ways to add logging to your Elysia application. | ||
|
||
### Preset request logging | ||
|
||
Currently, there are these [presets](./src/presets/index.ts) available to use. | ||
There are two ways to add logging to your Elysia application. The quickest way to use this logger is using a preset. | ||
|
||
```typescript | ||
import { Elysia } from 'elysia'; | ||
|
@@ -39,46 +33,17 @@ import { Logestic } from 'logestic'; | |
const app = new Elysia() | ||
.use(Logestic.preset('common')) | ||
.get('/', () => "Hello from server") | ||
.listen(5566); | ||
``` | ||
|
||
![Custom Preset](./screenshots/custom-preset.png) | ||
|
||
### Custom request logging | ||
|
||
If you don't like any of presets, you can configure Logestic to log your requests in your way. | ||
|
||
1. Create a `Logestic` instance, optionally where you wish to log. | ||
2. Call `use` to tell `Logestic` the information you wish to use. | ||
3. Finally, create an `Elysia` instance on `custom` with the formatting function. | ||
|
||
```typescript | ||
// ./logger.ts | ||
import { Logestic, chalk } from 'logestic'; | ||
|
||
// exports an Elysia instance | ||
export default new Logestic({ | ||
dest: Bun.file('request.log') | ||
}).use(['method', 'path', 'time', 'status']) | ||
.format({ | ||
onSuccess({ method, path, time, status }) { | ||
return `[${time}]: ${method} ${path} | ${status}` | ||
}, | ||
onFailure({ request, error, code, datetime }) { | ||
return chalk.red(`ERROR [${datetime}]: ${request.method} ${request.url} | ${code}`) | ||
} | ||
/* ... */ | ||
.listen(3000, () => { | ||
console.log("Server is running on port 3000") | ||
}); | ||
``` | ||
|
||
// ./index.ts | ||
import myLogger from './logger'; | ||
These [presets](https://github.com/cybercoder-naj/logestic/wiki/Presets) available to use. | ||
|
||
const app = new Elysia() | ||
.use(myLogger) | ||
.get('/', () => "Hello from server") | ||
.listen(5566); | ||
``` | ||
## Documentation | ||
|
||
Consider contributing your own preset; check [contributing guidelines](#contributing-guidelines). | ||
To view the full documentation, view the [wiki](https://github.com/cybercoder-naj/logestic/wiki/). | ||
|
||
## Contributing Guidelines | ||
|
||
|
@@ -87,7 +52,3 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) | |
## License | ||
|
||
[MIT](./LICENSE) | ||
|
||
## Authors | ||
|
||
- [@cybercoder-naj](https://github.com/cybercoder-naj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "logestic", | ||
"version": "0.5.2", | ||
"version": "1.0.0", | ||
"author": "Nishant Aanjaney Jalan <[email protected]>", | ||
"description": "An advanced and customisable logging library for ElysiaJS", | ||
"keywords": [ | ||
|
@@ -30,14 +30,14 @@ | |
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0", | ||
"elysia": "^1.0.0" | ||
"elysia": "^1.0.9" | ||
}, | ||
"devDependencies": { | ||
"@elysiajs/eden": "1.0.0", | ||
"@elysiajs/eden": "1.0.7", | ||
"bun-types": "latest", | ||
"elysia": "^1.0.9", | ||
"rimraf": "^5.0.5", | ||
"typescript": "^5.0.0", | ||
"elysia": "^1.0.0" | ||
"typescript": "^5.4.3" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.log |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.