Skip to content

Commit d579bd7

Browse files
Merge pull request #16 from cybercoder-naj/stable-release
Stable Release
2 parents 89e8530 + ac138ea commit d579bd7

16 files changed

+326
-223
lines changed

.github/workflows/publish-npm.yml

-16
This file was deleted.

CHANGELOG.md

+39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
11
# CHANGELOG
2+
## [1.0.0] - 2703-2024
3+
- First stable release! 🎆
4+
5+
## [1.0.0-alpha.6] - 27-03-2024
6+
### Fixed
7+
- Fix issues related to file logging. ([#14](https://github.com/cybercoder-naj/logestic/issues/14))
8+
9+
## [1.0.0-alpha.5] - 26-03-2024
10+
### Changed
11+
- Request duration returns time in microseconds.
12+
- `fancy` preset includes the duration on successful requests.
13+
14+
### Fixed
15+
- Incorrect status code when returning with `error` function ([#11](https://github.com/cybercoder-naj/logestic/issues/11))
16+
17+
## [1.0.0-alpha.4] - 26-03-2024
18+
### Added
19+
- Request duration as a logging feature ([#10](https://github.com/cybercoder-naj/logestic/issues/10))
20+
21+
## [1.0.0-alpha.3] - 25-03-2024
22+
### Changed
23+
- README file and updated the Wiki page.
24+
25+
### Fixed
26+
- Default configuration for `fancy` preset.
27+
28+
## [1.0.0-alpha.2] - 21-03-2024
29+
### Added
30+
- Customisable log type/level colour.
31+
- Option to disable implicit and explicit logging.
32+
- `build` function to create a logger wihout any `httpLogging`.
33+
34+
### Changed
35+
- Passing in options will override preset options.
36+
- Type loss when using Logestic middleware.
37+
38+
## [1.0.0-alpha.1] - 21-03-2024
39+
*Redacted. see 1.0.0-alpha.2 for changes*
40+
241
## [0.5.0] - 21-03-2024
342
### Added
443
- Origin/level of the log message, 'HTTP', 'ERROR', 'WARN', 'DEBUG', 'INFO'.

CONTRIBUTING.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
# Contributing to Logestic
22

3-
*Coming soon!*
3+
## Reporting Issues
4+
5+
😥 Feel free to submit an issue when Logestic is not working as you expected.
6+
7+
## Solving Issues
8+
9+
1. ❗ All PRs must reference an issue.
10+
2. 🗣 If there is an issue you want to work on, ask on the issue thread if you want to work on it.
11+
3. 🍴 Fork this repository and create a new branch `fix-[number]/[short description]` according to the issue.
12+
4. ✍ Fix the issue.
13+
6. 🎆 Open a PR and wait until a collaborator merges it in.
14+
15+
## Adding Presets
16+
17+
1. 🍴 Fork this repository and create a new branch `preset-[name]` with the name of your preset.
18+
2. ✍ Create a new file under [presets/](./src/presets/) and export an Elysia incstance with your Logestic middleware.
19+
3. ➕ Import your file in [index.ts](./src/presets/index.ts) and add the key type to [types](./src/types.ts)
20+
4. 🎆 Open a PR and wait until a collaborator merges it in. Attach a screenshot so we can add to the Wiki.

README.md

+10-49
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,21 @@ An advanced and customisable logging library for [ElysiaJS](https://elysiajs.com
1010
- [Table of Contents](#table-of-contents)
1111
- [Installation](#installation)
1212
- [Usage](#usage)
13-
- [Preset request logging](#preset-request-logging)
14-
- [Custom request logging](#custom-request-logging)
13+
- [Documentation](#documentation)
1514
- [Contributing Guidelines](#contributing-guidelines)
1615
- [License](#license)
17-
- [Authors](#authors)
1816

1917
## Installation
2018

21-
Add the package to your Elysia Project.
19+
Add the package to your Elysia Project via [bun](https://bun.sh).
2220
```bash
2321
bun add logestic
2422
```
2523
**Note**: You must have `elysia@1.0` installed in your project.
2624

2725
## Usage
2826

29-
There are two ways to add logging to your Elysia application.
30-
31-
### Preset request logging
32-
33-
Currently, there are these [presets](./src/presets/index.ts) available to use.
27+
There are two ways to add logging to your Elysia application. The quickest way to use this logger is using a preset.
3428

3529
```typescript
3630
import { Elysia } from 'elysia';
@@ -39,46 +33,17 @@ import { Logestic } from 'logestic';
3933
const app = new Elysia()
4034
.use(Logestic.preset('common'))
4135
.get('/', () => "Hello from server")
42-
.listen(5566);
43-
```
44-
45-
![Custom Preset](./screenshots/custom-preset.png)
46-
47-
### Custom request logging
48-
49-
If you don't like any of presets, you can configure Logestic to log your requests in your way.
50-
51-
1. Create a `Logestic` instance, optionally where you wish to log.
52-
2. Call `use` to tell `Logestic` the information you wish to use.
53-
3. Finally, create an `Elysia` instance on `custom` with the formatting function.
54-
55-
```typescript
56-
// ./logger.ts
57-
import { Logestic, chalk } from 'logestic';
58-
59-
// exports an Elysia instance
60-
export default new Logestic({
61-
dest: Bun.file('request.log')
62-
}).use(['method', 'path', 'time', 'status'])
63-
.format({
64-
onSuccess({ method, path, time, status }) {
65-
return `[${time}]: ${method} ${path} | ${status}`
66-
},
67-
onFailure({ request, error, code, datetime }) {
68-
return chalk.red(`ERROR [${datetime}]: ${request.method} ${request.url} | ${code}`)
69-
}
36+
/* ... */
37+
.listen(3000, () => {
38+
console.log("Server is running on port 3000")
7039
});
40+
```
7141

72-
// ./index.ts
73-
import myLogger from './logger';
42+
These [presets](https://github.com/cybercoder-naj/logestic/wiki/Presets) available to use.
7443

75-
const app = new Elysia()
76-
.use(myLogger)
77-
.get('/', () => "Hello from server")
78-
.listen(5566);
79-
```
44+
## Documentation
8045

81-
Consider contributing your own preset; check [contributing guidelines](#contributing-guidelines).
46+
To view the full documentation, view the [wiki](https://github.com/cybercoder-naj/logestic/wiki/).
8247

8348
## Contributing Guidelines
8449

@@ -87,7 +52,3 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md)
8752
## License
8853

8954
[MIT](./LICENSE)
90-
91-
## Authors
92-
93-
- [@cybercoder-naj](https://github.com/cybercoder-naj)

bun.lockb

1.17 KB
Binary file not shown.

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logestic",
3-
"version": "0.5.2",
3+
"version": "1.0.0",
44
"author": "Nishant Aanjaney Jalan <cybercoder.nishant@gmail.com>",
55
"description": "An advanced and customisable logging library for ElysiaJS",
66
"keywords": [
@@ -30,14 +30,14 @@
3030
},
3131
"peerDependencies": {
3232
"typescript": "^5.0.0",
33-
"elysia": "^1.0.0"
33+
"elysia": "^1.0.9"
3434
},
3535
"devDependencies": {
36-
"@elysiajs/eden": "1.0.0",
36+
"@elysiajs/eden": "1.0.7",
3737
"bun-types": "latest",
38+
"elysia": "^1.0.9",
3839
"rimraf": "^5.0.5",
39-
"typescript": "^5.0.0",
40-
"elysia": "^1.0.0"
40+
"typescript": "^5.4.3"
4141
},
4242
"publishConfig": {
4343
"access": "public"

preview/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.log

preview/bun.lockb

346 Bytes
Binary file not shown.

preview/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"homepage": "https://github.com/cybercoder-naj/logestic#readme",
1919
"dependencies": {
2020
"elysia": "^1.0.0",
21-
"logestic": ".."
21+
"logestic": "file:.."
2222
}
2323
}

preview/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Elysia } from 'elysia';
22
import { Logestic } from 'logestic';
33

44
const app = new Elysia()
5-
.use(Logestic.preset('common', { showType: true }))
5+
.use(Logestic.preset('fancy'))
66
.get('/', () => 'Hello, world!')
77
.get('/hello/:name', ({ params: { name } }) => `Hello, ${name}!`)
88
.get('/returnBad', ({ set }) => {

0 commit comments

Comments
 (0)