From 18fde3c08d3beca5d7ae9e7ecd14765c48a8f85f Mon Sep 17 00:00:00 2001 From: "Jason R. Stevens, CFA" Date: Fri, 17 Jan 2025 20:41:28 -0500 Subject: [PATCH] docs: update API portion of documentation --- README.md | 129 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 97 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index c240749..d6fcad0 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # @tincre/logger -[![npm package][npm-img]][npm-url] -[![Build Status][build-img]][build-url] -[![Downloads][downloads-img]][downloads-url] -[![Issues][issues-img]][issues-url] -[![Code Coverage][codecov-img]][codecov-url] -[![Commitizen Friendly][commitizen-img]][commitizen-url] +[![npm package][npm-img]][npm-url] +[![Build Status][build-img]][build-url] +[![Downloads][downloads-img]][downloads-url] +[![Issues][issues-img]][issues-url] +[![Code Coverage][codecov-img]][codecov-url] +[![Commitizen Friendly][commitizen-img]][commitizen-url] [![Semantic Release][semantic-release-img]][semantic-release-url] ## Install @@ -19,42 +19,107 @@ npm install @tincre/logger ```ts import { logger } from '@tincre/logger'; -logger.debug('hello'); -//=> 'hello' in logging output +logger.debug('Debugging message'); +logger.log('Application started'); +logger.warn('This is a warning'); +logger.error('Unexpected error occurred', new Error('Something went wrong')); ``` ## API -### myPackage(input, options?) +### `logger.log(message, data?)` -#### input +Logs a standard message to the console if `NODE_ENV` is **not** set to `production`. -Type: `string` +#### Parameters: -Lorem ipsum. +- `message`: **string** - The main log message. +- `data` (optional): **unknown** - Additional data (object, array, string, etc.). -#### options +#### Example: -Type: `object` +```ts +logger.log('User logged in', { userId: 123 }); +``` + +--- + +### `logger.error(message, data?)` + +Logs an error message to the console if `NODE_ENV` is **not** set to `production`. + +#### Parameters: + +- `message`: **string** - The error message. +- `data` (optional): **unknown** - Additional error details. + +#### Example: + +```ts +logger.error('Database connection failed', new Error('Connection timeout')); +``` + +--- + +### `logger.warn(message, data?)` + +Logs a warning message to the console if `NODE_ENV` is **not** set to `production`. + +#### Parameters: + +- `message`: **string** - The warning message. +- `data` (optional): **unknown** - Additional details. + +#### Example: + +```ts +logger.warn('Low disk space', { availableGB: 2 }); +``` + +--- + +### `logger.debug(message, data?)` + +Logs a debug message to the console if `NODE_ENV` is **not** set to `production`. + +#### Parameters: + +- `message`: **string** - The debug message. +- `data` (optional): **unknown** - Additional debug info. + +#### Example: + +```ts +logger.debug('Fetching API data', { endpoint: '/users', method: 'GET' }); +``` + +--- + +## Environment Variables + +| Variable | Description | +| ---------- | -------------------------------------------------------------------- | +| `NODE_ENV` | Set to `"production"` to disable logging in production environments. | + +--- -##### postfix +## Contributing -Type: `string` -Default: `rainbows` +We welcome contributions! Please follow our commit guidelines and open issues if you encounter any problems. -Lorem ipsum. +--- -[build-img]:https://github.com/Tincre/logger/actions/workflows/release.yml/badge.svg -[build-url]:https://github.com/Tincre/logger/actions/workflows/release.yml -[downloads-img]:https://img.shields.io/npm/dt/@tincre/logger -[downloads-url]:https://www.npmtrends.com/@tincre/logger -[npm-img]:https://img.shields.io/npm/v/@tincre/logger -[npm-url]:https://www.npmjs.com/package/@tincre/logger -[issues-img]:https://img.shields.io/github/issues/Tincre/logger -[issues-url]:https://github.com/Tincre/logger/issues -[codecov-img]:https://codecov.io/gh/Tincre/logger/branch/main/graph/badge.svg -[codecov-url]:https://codecov.io/gh/Tincre/logger -[semantic-release-img]:https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg -[semantic-release-url]:https://github.com/semantic-release/semantic-release -[commitizen-img]:https://img.shields.io/badge/commitizen-friendly-brightgreen.svg -[commitizen-url]:http://commitizen.github.io/cz-cli/ +[build-img]: https://github.com/Tincre/logger/actions/workflows/release.yml/badge.svg +[build-url]: https://github.com/Tincre/logger/actions/workflows/release.yml +[downloads-img]: https://img.shields.io/npm/dt/@tincre/logger +[downloads-url]: https://www.npmtrends.com/@tincre/logger +[npm-img]: https://img.shields.io/npm/v/@tincre/logger +[npm-url]: https://www.npmjs.com/package/@tincre/logger +[issues-img]: https://img.shields.io/github/issues/Tincre/logger +[issues-url]: https://github.com/Tincre/logger/issues +[codecov-img]: https://codecov.io/gh/Tincre/logger/branch/main/graph/badge.svg +[codecov-url]: https://codecov.io/gh/Tincre/logger +[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg +[semantic-release-url]: https://github.com/semantic-release/semantic-release +[commitizen-img]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg +[commitizen-url]: http://commitizen.github.io/cz-cli/