0.0.5 • Published 9 months ago
@tincre/logger v0.0.5
@tincre/logger
Install
npm install @tincre/loggerUsage
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.