Metadata-Version: 2.1
Name: loggerV
Version: 1.0.0
Summary: A logger class and a decorator that works with that class for python
Project-URL: Homepage, https://github.com/aaronv15/logger_v-python
Project-URL: Bug Tracker, https://github.com/aaronv15/logger_v-python/issues
Author-email: Aharon Vegoda <aaronvegoda@gmail.com>
Maintainer-email: Aharon Vegoda <aaronvegoda@gmail.com>
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown

# logger_v-python
A logger class and decorator for python
## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install logger_v-python.

```bash
pip install loggerV
```

## Basic Usage

```python
from loggerV import Logger


# Creates an instance of class Logger
logger = Logger("Logger")

logger.append(
    step="First Log",
    message="Testing",
    success=True,
)
```

## Advanced Usage

```python
from loggerV import Logger
from loggerV import funcLogger


# Create a custom dataclass to use in the logger
class Example:
    def __init__(self, one, two) -> None:
        self.one = one
        self.two = two


# Create a new instance of the Logger class
logger = Logger(name="Logger")


# A method decorated with the funcLogger method. It accepts the logger as an argument.
# fail is what precedence the logger should use if the decorated functions fails. (Optional)
# success is what precedence the logger should use if the decorated function succeeds. (Optional)
# run is what level of logging to use. 0: no loging, even if it fails. 1: log if the function fails. 2: log whether it failsor succeeds
@funcLogger(logger)
def convert(string, run=0, fail=None, success=None):
    return int(string)


# Load the custom class so that it can be used in the logger
logger.loadCustom(
    names=["fieldOne", "fieldTwo"],
    printValues=["One", "Two"],
    defaults=None,
    dontPrintIf=None,
)

# The way partitions work is that each partition has a precedence. There are two partitions by default. main with a precedence of 3 and footer with a precedence of ten.
# Partitions and precedence can be created through the below method, and can be used in the append function. by default append uses partition main (3). 
# Logs in the same partition are ordered by first come first serve
logger.addPartition(name="first", precedence=1)


# Create a new Log
logger.append(
    step="First Log",
    message="Testing",
    custom=Example(
        one="Hello", two="World"
        ),
    success=True,
    partition="main",
)
logger.append("Second Log", "Testing", success=False, partition=1)
logger.append("Third Log")

print(logger)
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License

[MIT](https://choosealicense.com/licenses/mit/)
