Metadata-Version: 2.1
Name: tracebook
Version: 0.1.3
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

To log function calls, parameters, return values, and execution times, you can use the logging functionality:

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

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

@logger.trace(log_resources=True)
def fact(x):
    if x == 0:
        return 1
    else:
        return x * fact(x - 1)

@logger.trace(log_resources=True)
def fibonacci(n):
    if n <= 0:
        return 0
    elif n == 1:
        return 1
    else:
        return fibonacci(n - 1) + fibonacci(n - 2)

@logger.trace(log_resources=True)
def complex_operation(x):
    fact_result = fact(x)
    fib_result = fibonacci(x)
    return fact_result + fib_result

if __name__ == "__main__":
    while True:
        x = int(input("Enter a number: "))
        result = complex_operation(x)
        print(f"Result of complex operation with {x}: {result}")
```

### Using Decorators

To simplify logging, you can use the provided decorators:

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

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

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

my_function(1, 2)
```

### Remote Log Transmission

To send logs to a remote server, configure the remote settings in `Config`:

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

logger = Logger(
    config=Config(
        log_level=LogLevel.INFO,
        output="file",
        file_path="test.log",
        remote_config=RemoteConfig(
            url="https://yourserver.com/log",
            headers={"Authorization": "Bearer yourapikey"}
        )
    )
)

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

my_function(1, 2)
```

### 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.
