https://github.com/chewhx/loglert
Log and print messages with levels and style
https://github.com/chewhx/loglert
cli command-line log-level logger logging nodejs terminal
Last synced: 2 months ago
JSON representation
Log and print messages with levels and style
- Host: GitHub
- URL: https://github.com/chewhx/loglert
- Owner: chewhx
- Created: 2022-09-13T13:31:44.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-13T13:40:16.000Z (over 2 years ago)
- Last Synced: 2025-01-20T15:19:45.602Z (4 months ago)
- Topics: cli, command-line, log-level, logger, logging, nodejs, terminal
- Language: TypeScript
- Homepage:
- Size: 104 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# loglert
> Log and print messages with levels and style
- Adapted from [cli-alerts](https://www.npmjs.com/package/cli-alerts) by Ahmad Awais
- Supports types for your typescript projects
- Print the styled log message as string to in your own logger - `.print`
- Convenient methods to log message levels: `.success` , `.info`, `.warning`, `.error`
- Smaller package size: less than 6kB
- If you wish to customize further, you will be better off using [chalk](https://www.npmjs.com/package/chalk) and [log-symbols](https://www.npmjs.com/package/log-symbols)# Install
```bash
npm install loglert
```# Usage
```javascript
import { loglert } from 'loglert';loglert.success(`Update successful!`);
```# API
## loglert(options)
```javascript
loglert({ msg: 'Updating info', type: 'success', name: 'DONE' });
```### options
#### msg
Type: `string`
Required: true
#### type?
Type: `'success' | 'error' | 'info' | 'warning'`
Default: `'info'`
#### showName?
Type: `boolean`
Default: true
#### name?
Type: `string`
Default: 'INFO'
## loglert.success('message', opts)
Logs a success type message.
## loglert.error('message',opts)
Logs an error type message.
## loglert.info('message',opts)
Logs an info type message.
## loglert.warning('message',opts)
Logs a warning type message.
## loglert.print('message',opts)
Returns a string of the type message. You may use this string in your own logger.
### opts
#### showName?
Type: `boolean`
Default: true
#### name?
Type: `string`
Default: 'INFO'
# License
ISC ©️ Chew Han Xiang
# Author
**Chew Han Xiang**
- [https://www.chewhx.com/](https://www.chewhx.com/)
- [https://github.com/chewhx](https://github.com/chewhx)
- [https://www.linkedin.com/in/chewhx/](https://www.linkedin.com/in/chewhx/)