Skip to content

Tincre/logger

Repository files navigation

@tincre/logger

npm package
Build Status
Downloads
Issues
Code Coverage
Commitizen Friendly
Semantic Release

Install

npm install @tincre/logger

Usage

import { logger } from '@tincre/logger';

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

logger.log(message, data?)

Logs a standard message to the console if NODE_ENV is not set to production.

Parameters:

  • message: string - The main log message.
  • data (optional): unknown - Additional data (object, array, string, etc.).

Example:

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:

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:

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:

logger.debug('Fetching API data', { endpoint: '/users', method: 'GET' });

Environment Variables

Variable Description
NODE_ENV Set to "production" to disable logging in production environments.

Contributing

We welcome contributions! Please follow our commit guidelines and open issues if you encounter any problems.


About

A console.log wrapper for TypeScript projects

Resources

License

Stars

Watchers

Forks

Packages

No packages published