Metadata-Version: 2.2
Name: asynclogger
Version: 0.1.0
Summary: A lightweight and efficient asynchronous logging package for Python
Home-page: https://github.com/ixlammm/asynclogger
Author: Islam Tazerout
Author-email: islamtazerout3@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: aiofile
Requires-Dist: colorist
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# asynclogger

A lightweight and efficient asynchronous logging package for logging messages to the console and files. Supports colored output, dynamic log paths, and customizable log levels.

## Features

- **Asynchronous Logging**: Non-blocking logging for improved performance.
- **Console and File Logging**: Supports simultaneous logging to console and files.
- **Colored Output**: Differentiates log levels using colors for better readability.
- **Dynamic Log Paths**: Change log file paths dynamically without restarting.
- **Custom Log Levels**: Define and configure custom logging levels.

## Installation

```sh
pip install asynclogger
```

## Usage

### Basic Example

```python
from asynclogger import logger

logger.config('./logs/test.log', log_to_console=True)

async def main():
    await logger.info('Hello, world!')

if __name__ == '__main__':
    asyncio.run(main())
```

### Configuration Options

| Option         | Type    | Default         | Description |
|----------------|--------|---------------|-------------|
| `log_format`  | String | `{isoformat} {group} {level} {message}` | Format used for logging messages. |
| `output` | List | `["console"]` | Specifies outputs. |
| `colorize`  | Boolean or Dict | `True` | Takes either a boolean or a dict specifying a color for each log level. |
| `wrapper`     | Dict | `{}` | Contains a dict of wrapper functions for each format variable (isoformat, group, level ...). |

### Dynamic Log Path Change

```python
logger.config('./logs/%Y/%B/{safedate}.log', log_to_console=True)
```

### Custom Log Levels

```python
await logger.log('custom', 'This is a custom log level message')
```

### Coloring Output

```python
from colorist import Color

logger.config('./logs/test.log', log_to_console=True, colorize={
    'ERROR': Color.GREEN
})
```

### Wrapping Variables

```python
logger.config('./logs/test.log', log_to_console=True, wrapper={'group': lambda x: f'({x})'})
```

## License

MIT

