Skip to content

Commit

Permalink
Merge pull request #16 from cybercoder-naj/stable-release
Browse files Browse the repository at this point in the history
Stable Release
  • Loading branch information
cybercoder-naj authored Mar 27, 2024
2 parents 89e8530 + ac138ea commit d579bd7
Show file tree
Hide file tree
Showing 16 changed files with 326 additions and 223 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/publish-npm.yml

This file was deleted.

39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
# CHANGELOG
## [1.0.0] - 2703-2024
- First stable release! 🎆

## [1.0.0-alpha.6] - 27-03-2024
### Fixed
- Fix issues related to file logging. ([#14](https://github.com/cybercoder-naj/logestic/issues/14))

## [1.0.0-alpha.5] - 26-03-2024
### Changed
- Request duration returns time in microseconds.
- `fancy` preset includes the duration on successful requests.

### Fixed
- Incorrect status code when returning with `error` function ([#11](https://github.com/cybercoder-naj/logestic/issues/11))

## [1.0.0-alpha.4] - 26-03-2024
### Added
- Request duration as a logging feature ([#10](https://github.com/cybercoder-naj/logestic/issues/10))

## [1.0.0-alpha.3] - 25-03-2024
### Changed
- README file and updated the Wiki page.

### Fixed
- Default configuration for `fancy` preset.

## [1.0.0-alpha.2] - 21-03-2024
### Added
- Customisable log type/level colour.
- Option to disable implicit and explicit logging.
- `build` function to create a logger wihout any `httpLogging`.

### Changed
- Passing in options will override preset options.
- Type loss when using Logestic middleware.

## [1.0.0-alpha.1] - 21-03-2024
*Redacted. see 1.0.0-alpha.2 for changes*

## [0.5.0] - 21-03-2024
### Added
- Origin/level of the log message, 'HTTP', 'ERROR', 'WARN', 'DEBUG', 'INFO'.
Expand Down
19 changes: 18 additions & 1 deletion CONTRIBUTING.md
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.
59 changes: 10 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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

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

[MIT](./LICENSE)

## Authors

- [@cybercoder-naj](https://github.com/cybercoder-naj)
Binary file modified bun.lockb
Binary file not shown.
10 changes: 5 additions & 5 deletions package.json
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": [
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions preview/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.log
Binary file modified preview/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"homepage": "https://github.com/cybercoder-naj/logestic#readme",
"dependencies": {
"elysia": "^1.0.0",
"logestic": ".."
"logestic": "file:.."
}
}
2 changes: 1 addition & 1 deletion preview/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Elysia } from 'elysia';
import { Logestic } from 'logestic';

const app = new Elysia()
.use(Logestic.preset('common', { showType: true }))
.use(Logestic.preset('fancy'))
.get('/', () => 'Hello, world!')
.get('/hello/:name', ({ params: { name } }) => `Hello, ${name}!`)
.get('/returnBad', ({ set }) => {
Expand Down
Loading

0 comments on commit d579bd7

Please sign in to comment.