generated from ericz99/starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
63 additions
and
10 deletions.
There are no files selected for viewing
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,15 +1,68 @@ | ||
# pkg-name | ||
# Loggy | ||
|
||
[![NPM version](https://img.shields.io/npm/v/pkg-name?color=a1b858&label=)](https://www.npmjs.com/package/pkg-name) | ||
> Simplify logging in your application | ||
## Sponsors | ||
# Installation | ||
|
||
<p align="center"> | ||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg"> | ||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/> | ||
</a> | ||
</p> | ||
```bash | ||
npm install loggy | ||
``` | ||
|
||
## License | ||
# Usage | ||
|
||
[MIT](./LICENSE) License © 2022 [Anthony Fu](https://github.com/antfu) | ||
```typescript | ||
|
||
import { createLogger, Loggy } from 'loggy' | ||
|
||
// You can use either to initialize an instance in 2 ways | ||
|
||
// 1. one way | ||
const logger = createLogger({ | ||
path: 'some-path', | ||
formatMessageTemplate: '😊 ({TIME}) - ({LEVEL}) - >> {MESSAGE}', | ||
backupDuration: 3600 * 1000 // 1 hour | ||
shouldBackUp: true, | ||
cloud: { | ||
ut: { | ||
apiKey: '...' | ||
} | ||
} | ||
}); | ||
|
||
// 2. second way | ||
const logger = new Loggy({ | ||
path: 'some-path', | ||
formatMessageTemplate: '😊 ({TIME}) - ({LEVEL}) - >> {MESSAGE}', | ||
backupDuration: 3600 * 1000 // 1 hour | ||
shouldBackUp: true, | ||
cloud: { | ||
ut: { | ||
apiKey: '...' | ||
} | ||
} | ||
}); | ||
|
||
// # list of available logging method | ||
|
||
logger.debug('hi this debug'); | ||
logger.warn('hello this is warn') | ||
logger.error('hello this is error') | ||
logger.info('hello this is info') | ||
logger.silly('hello this is silly') | ||
logger.custon('hello this is custom') | ||
|
||
``` | ||
|
||
# API Reference | ||
|
||
## LoggyOptions | ||
|
||
To configure the Cloud Backup Service, users need to provide the following parameters: | ||
|
||
- path: The path to the data to be backed up. | ||
- formatMessageTemplate: The template for formatting log messages. Supported placeholders include {TIME}, {LEVEL}, and {MESSAGE}. | ||
- backupDuration: The duration (in milliseconds) between backups. Default is set to 1 hour. | ||
- shouldBackUp: A boolean indicating whether backups should be performed. | ||
- cloud: Configuration for the cloud storage provider. | ||
- ut: Configuration specific to the cloud provider. Currently, only API key is supported. | ||
- apiKey: The API key for accessing the cloud storage provider. |