Metadata-Version: 2.1
Name: tracebook
Version: 0.1.7
Summary: A comprehensive code bookkeeping package
Author: Sujal Choudhari
Author-email: hello@sujal.xyz
Keywords: book-keeping,visualizer
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: blinker==1.8.2
Requires-Dist: certifi==2024.7.4
Requires-Dist: charset-normalizer==3.3.2
Requires-Dist: click==8.1.7
Requires-Dist: colorama==0.4.6
Requires-Dist: dash==2.17.1
Requires-Dist: dash-bootstrap-components==1.6.0
Requires-Dist: dash-core-components==2.0.0
Requires-Dist: dash-html-components==2.0.0
Requires-Dist: dash-table==5.0.0
Requires-Dist: docutils==0.21.2
Requires-Dist: Flask==3.0.3
Requires-Dist: idna==3.7
Requires-Dist: importlib_metadata==8.2.0
Requires-Dist: itsdangerous==2.2.0
Requires-Dist: jaraco.classes==3.4.0
Requires-Dist: jaraco.context==5.3.0
Requires-Dist: jaraco.functools==4.0.2
Requires-Dist: Jinja2==3.1.4
Requires-Dist: keyring==25.3.0
Requires-Dist: markdown-it-py==3.0.0
Requires-Dist: MarkupSafe==2.1.5
Requires-Dist: mdurl==0.1.2
Requires-Dist: more-itertools==10.4.0
Requires-Dist: nest-asyncio==1.6.0
Requires-Dist: nh3==0.2.18
Requires-Dist: packaging==24.1
Requires-Dist: pkginfo==1.10.0
Requires-Dist: plotly==5.23.0
Requires-Dist: psutil==6.0.0
Requires-Dist: Pygments==2.18.0
Requires-Dist: pywin32-ctypes==0.2.2
Requires-Dist: readme_renderer==44.0
Requires-Dist: requests==2.32.3
Requires-Dist: requests-toolbelt==1.0.0
Requires-Dist: retrying==1.3.4
Requires-Dist: rfc3986==2.0.0
Requires-Dist: rich==13.7.1
Requires-Dist: setuptools==72.1.0
Requires-Dist: six==1.16.0
Requires-Dist: tenacity==9.0.0
Requires-Dist: typing_extensions==4.12.2
Requires-Dist: urllib3==2.2.2
Requires-Dist: watchdog==4.0.2
Requires-Dist: Werkzeug==3.0.3
Requires-Dist: wheel==0.44.0
Requires-Dist: zipp==3.20.0

# Trace Book

**Trace Book** is a Python package designed for comprehensive code bookkeeping. It provides tools to log function calls, parameters, return values, and execution times. Additionally, it supports decorators for easy integration, automatic error tracking, and remote log transmission, all with customizable log levels and output configurations.

## Features

- **Function Logging**: Track function calls, parameters, return values, and execution times.
- **Automatic Error Tracking**: Log exceptions and stack traces automatically.
- **Decorators**: Simplify logging with decorators that track function parameters and results.
- **Remote Log Transmission**: Securely send logs to a remote server.
- **Customizable Log Levels**: Control log verbosity with DEBUG, INFO, WARNING, and ERROR levels.
- **Configurable Output**: Choose between logging to files or transmitting logs to a remote server.

## Installation

You can install **Trace Book** using `pip`:

```bash
pip install tracebook
```

Or by cloning the repository and installing it manually:

```bash
git clone https://github.com/yourusername/tracebook.git
cd tracebook
pip install .
```

## Usage

### Basic Logging

```python
from tracebook import Logger
from tracebook.config import Config, LogLevel

logger = Logger(config=Config(log_level=LogLevel.INFO, output="both", file_path="app.log"))

@logger.trace()
def add(a, b):
    return a + b

result = add(3, 5)
print(f"Result: {result}")
```

### Logging with Resource Tracking

```python
@logger.trace(log_resources=True)
def compute_factorial(n):
    if n == 0:
        return 1
    return n * compute_factorial(n - 1)

compute_factorial(5)
```

### Using Different Log Levels

```python
logger.debug("Debugging information")
logger.info("General information")
logger.warning("Warning: resource running low")
logger.error("Error occurred: unable to connect")
logger.critical("Critical: system shutdown imminent")
```

### Exception Handling

```python
@logger.trace()
def divide(a, b):
    return a / b

try:
    divide(10, 0)
except ZeroDivisionError:
    logger.error("Attempted division by zero")
```

### Remote Logging Configuration

```python
from tracebook.config import RemoteConfig

remote_logger = Logger(
    config=Config(
        log_level=LogLevel.INFO,
        output="remote",
        remote_config=RemoteConfig(
            url="https://logs.example.com",
            headers={"Authorization": "Bearer your-token"}
        )
    )
)

@remote_logger.trace()
def important_function():
    # Function logic here
    pass
```
### Configuring Log Levels and Output

Control the verbosity of logs by setting the log level and choosing the output:

```python
from tracebook import Logger
from tracebook.config import Config, LogLevel

logger = Logger(
    config=Config(
        log_level=LogLevel.DEBUG,
        output="both",
        file_path="logs.txt"
    )
)

@logger.trace(log_resources=True)
def my_function(param1, param2):
    return param1 + param2

my_function(1, 2)
```


## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
