A TypeScript library for enhancing and formatting log messages.
- Pretty-print log messages in different styles.
- Supports both CommonJS and ES modules.
- Written in TypeScript with type definitions included.
- Easy to use and integrate into any project.
You can install directly from GitHub:
npm install git+https://github.com/louisxie0830/pretty-log.gitHere are examples of how to import and use this library in different projects:
const prettyLog = require('pretty-log').default;
const logger = prettyLog({ enabled: true });
logger.info('Hello, World!');
logger.error('Hello, World!');
logger.warn('Hello, World!');
logger.success('Hello, World!');import prettyLog from 'pretty-log';
const logger = prettyLog({ enabled: true });
logger.info('Hello, World!');
logger.error('Hello, World!');
logger.warn('Hello, World!');
logger.success('Hello, World!');import prettyLog from 'pretty-log';
const logger = prettyLog({ enabled: true });
logger.info('Hello, World!');
logger.error('Hello, World!');
logger.warn('Hello, World!');
logger.success('Hello, World!');- options: An object with the following properties:
- enabled:
boolean- Enable or disable logging.
- enabled:
- info(message: string, content?: string): Logs an informational message.
- error(message: string, content?: string): Logs an error message.
- warn(message: string, content?: string): Logs a warning message.
- success(message: string, content?: string): Logs a success message.
- setEnabled(enabled: boolean): Enables or disables logging.
To build the project, run:
npm run buildThis will generate the CommonJS and ES module versions of the library in the dist directory.
To run tests, use:
npm testThis will run the tests using Jest.
To lint the code, use:
npm run lintTo format the code, use:
npm run formatsrc/: Source code files.tests/: Test files.dist/: Compiled output files.package.json: Project metadata and dependencies.tsconfig.json: TypeScript configuration.tsconfig.cjs.json: TypeScript configuration for CommonJS modules.tsconfig.esm.json: TypeScript configuration for ES modules.jest.config.js: Jest configuration..eslintrc.json: ESLint configuration..prettierrc: Prettier configuration..prettierignore: Files ignored by Prettier..eslintignore: Files ignored by ESLint..gitignore: Files ignored by Git.
Contributions are welcome! Please open an issue or submit a pull request for any changes.
This project is licensed under the MIT License - see the LICENSE file for details.
Author: Nil Xie
Email: bfgh2678@gmail.com
GitHub: louisxie0830