Metadata-Version: 2.1
Name: logthon
Version: 2.5.0
Summary: A simple logger for Python
Home-page: https://github.com/mastrobirraio/logthon
Author: Giuseppe "mastrobirraio" Matranga
Author-email: matrangagiuseppe99@gmail.com
Maintainer: Giuseppe "mastrobirraio" Matranga
License: GPLv3
Keywords: log logger logging logthon ansi crossplatform xplatform
Platform: UNKNOWN
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.0
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Terminals
Requires-Python: >=2.7
Description-Content-Type: text/markdown
License-File: LICENSE

# Logthon

A simple logger for Python

## Getting Started

These instructions will install the logger to your machine.

### Prerequisites

* Python3
* PIP3

### Installation

```
pip3 install logthon
```

## Usage


### Import

#### Classic import

```
from logthon.logthon import Logthon as Logger

Logthon = Logger()
```

#### Save output on file

```
from logthon import Logthon as Logger

Logthon = Logger(save_log=True)
```

#### Save output on custom file

```
from logthon import Logthon as Logger

Logthon = Logger(save_log=True, filename='/path/to/file')
```

### Define module name on log format

```
from logthon import Logthon as Logger

Logthon = Logger(module_name=__name__)  # or Logger(module_name='my.module.path')

# Example
Logthon.info('This is an info log')
# [2012-01-14 00:00:00] my.module.path - INFO: This is an info log
```

### Info level

```
Logthon.info('This is an info log')
# [2012-01-14 00:00:00] INFO: This is an info log
```

### Warn level

```
Logthon.warn('This is a warn log')
# [2012-01-14 00:00:00] WARN: This is a warn log
```

### Error level

```
Logthon.error('This is an error log')
# [2012-01-14 00:00:00] ERROR: This is an error log
```

### Success level

```
Logthon.success('This is a success log')
# [2012-01-14 00:00:00] SUCCESS: This is a success log
```

### Critical level

```
Logthon.critical('This is a critical log')
# [2012-01-14 00:00:00] CRITICAL: This is a critical log
```

### Debug level

```
Logthon.debug('This is a debug log')
# [2012-01-14 00:00:00] DEBUG: This is a debug log
```

## Log and exit program with error code
You can log a message and exit the program defining optionally and error code.
```
# Default log level is CRITICAL
# Default error code is 1
Logthon.log_and_exit_with_code('This is a message')
```

## Disable debug level log printing
```
logthon = Logthon(debug=False)
logthon.debug('This is a debug log')

# Nothing printed
```

If you want to define log level, you need to import level you want
```
from logthon.logthon import INFO_LEVEL
from logthon.logthon import WARN_LEVEL
from logthon.logthon import ERRO_LEVEL
from logthon.logthon import SUCC_LEVEL
from logthon.logthon import CRITICAL_LEVEL
from logthon.logthon import DEBUG_LEVEL

# e.g. we want to log with error level and exit
Logthon.log_and_exit_with_code('Log message', level=ERRO_LEVEL)

# e.g. we want to log with debug level and exit with code 5
Logthon.log_and_exit_with_code('Log message', level=DEBUG_LEVEL, error_code=5)
```

## Log a prettified dictionary 
You can log a message with a dictionary pretty printed
```
# Default log level is DEBUG 
Logthon.pretty_print('This is a message', {'key': 'word'})
```

If you want to define log level, you need to import level you want
```
from logthon.logthon import INFO_LEVEL
from logthon.logthon import WARN_LEVEL
from logthon.logthon import ERRO_LEVEL
from logthon.logthon import SUCC_LEVEL
from logthon.logthon import CRITICAL_LEVEL
from logthon.logthon import DEBUG_LEVEL

# e.g. we want to log with info level
Logthon.pretty_print('This is a message', {'key': 'word'}, level=INFO_LEVEL)
```
## Contributing

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on code of conduct, and the process for submitting pull requests.

## License

This project is licensed under the GNU General Public License v3 (GPLv3), read [LICENSE](LICENSE) for details 

## Author

* **Giuseppe "mastrobirraio" Matranga** - *Initial work* - [Github](https://github.com/mastrobirraio)


