# Logger

Logger is a simple yet effective built-in logging module designed to help you log application activity, warnings, errors, and debug information. This logger can be used throughout the application, whether in services, middleware, or modules.

## Purpose

* Simplifies real-time application activity.
* Consistently differentiates message types (info, warn, error, debug).
* Supports debug output only in development mode.

## API Reference

| Method | Description |
| ------------------------ | ----------------------------------------------------------------------- |
| `Logger.info(msg, ...)` | Logs general information. Used for normal logging. |
| `Logger.warn(msg, ...)` | Logs warnings. Typically for events that do not terminate the process. |
| `Logger.error(msg, ...)` | Logs errors. Typically when an exception or critical failure occurs. |
| `Logger.debug(msg, ...)` | Logs debug messages, only appears when `NODE_ENV=development`. |

## Usage Examples

**Logging General Information**

```javascript
import { Logger } from 'fhyts';

Logger.info('Server running on port 3000');
```

**Note the Warning**

```javascript
Logger.warn('Cache not found, continue without cache');
```

**Logging Errors**

```javascript
try {
  throw new Error('Failed to connect to database');
} catch (err) {
  Logger.error('Connection error:', err);
}
```

## Best Practices

* Use **info()** for success messages or general application flow.
* Use **warn()** for abnormal but non-fatal conditions.
* Use **error()** to log exceptions, failures, or serious issues.
* Use **debug()** for development purposes; avoid it in production.

## Next

Once you understand how to use Logger, you can move on to the [Error Handler](#error-handler) section to learn how to handle errors centrally and responsively in your application.