openlog


Nameopenlog JSON
Version 2.0.0 PyPI version JSON
download
home_pageNone
SummaryOpen-source minimal Rich-based logging solution
upload_time2025-08-10 15:07:25
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords logs file-logging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenLog

A versatile Python logging utility (overengineered python-rich wrapping) designed to enhance logging capabilities with
rich console output and optional file logging.

## Features

- 🎨 **Rich Console Output**: Color-coded messages with beautiful formatting
- 📁 **Flexible File Logging**: Optional file output with session support
- 🔧 **Task Management**: Progress-bars, special task logging etc.
- 📊 **Multiple Log Levels**: INFO, ERROR, WARN, and INIT with distinct styling
- 💾 **In-Memory Storage**: Retrieve and manage logs programmatically
- 🎯 **Prefix Support**: Add context to your log messages
- 📐 **Terminal-Aware**: Automatic width detection for optimal formatting

## Installation

```bash
pip install openlog
```

## Quick Start

### Basic Console Logging

```python
from openlog import Logger

logger = Logger()
logger.log("This is an info message")
logger.error("Something went wrong")
logger.warn("This is a warning")
logger.init("System initialized")
```

### Batch Logging

```python
# Add multiple messages

logger.batch.add_message("Processing started")
logger.batch.add_message("Loading configuration")
logger.batch.add_message("Connecting to database")

# Log all messages in the batch
logger.flush_batch()
```

### File Logging

```python
# Basic file logging
file_logger = Logger(write_to_file=True)
file_logger.log("This message goes to console and file")

# Session-based logging (timestamped files)
session_logger = Logger(write_to_file=True, session=True)
session_logger.log("Logged with timestamp in filename")

# Organized in /logs directory
dir_logger = Logger(in_dir=True, write_to_file=True)
dir_logger.log("Logs stored in /logs directory")
```

### Task Management

OpenLog supports tracking long-running tasks with animated progress bars:

```python
logger = Logger()

# Start a task with progress bar
task_id = logger.add_task("Processing large dataset")

# Your long-running code here
# ...

# Stop the task
logger.stop_task(task_id)
```

#### Task Management Methods:

- add_task(task_message) - Start a task with progress display
- stop_task(task_id) - Stop a specific task
- get_active_tasks() - Get all currently running tasks
- stop_all_tasks() - Stop all active tasks (useful for cleanup)

### Smart Object Formatting

```python
# Simple objects stay inline
logger.log({"user": "Alice", "id": 123})

# Complex objects format vertically
complex_data = {
    "users": [
        {"id": 1, "name": "Alice", "roles": ["admin", "user"]},
        {"id": 2, "name": "Bob", "roles": ["user", "viewer"]},
    ],
    "settings": {
        "theme": "dark",
        "notifications": {"email": True, "push": False}
    }
}
logger.log("User data:")
logger.log(complex_data)
```

### Retrieve Logs Programmatically

```python
# Get recent logs
logs = logger.flush_logs()

# Get all logs from start
all_logs = logger.flush_logs(from_start=True)
```

## Documentation

For detailed information about all features, configuration options, and advanced usage, see [FEATURES.md](FEATURES.md).

## Configuration

| Parameter       | Type | Default | Description                     |
|-----------------|------|---------|---------------------------------|
| `write_to_file` | bool | False   | Enable file logging             |
| `in_dir`        | bool | False   | Store logs in `/logs` directory |
| `session`       | bool | False   | Create timestamped log files    |
| `prefix`        | str  | ""      | Add prefix to all messages      |

#### Log Levels and Methods

- `log()` - General information (blue)
- `error()` - Error messages (red)
- `warn()` - Warning messages (yellow)
- `init()` - Initialization messages (purple)

#### Batch Operations

- `add_to_batch()` - Add message to batch
- `flush_batch()` - Output all batched messages
- `clear_batch()` - Clear batch without output
- `batch_size()` - Get number of messages in batch

#### Task Management

- `add_task()` - Start task with progress bar
- `stop_task()` - Stop specific task
- `get_active_tasks()` - Get active task information
- `stop_all_tasks()` - Stop all tasks and cleanup

## Requirements

- Python 3.9+
- Rich library (automatically installed)

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Links

- [GitHub Repository](https://github.com/Hexerpowers/openlog)
- [Detailed Features Documentation](FEATURES.md)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "openlog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "logs, file-logging",
    "author": null,
    "author_email": "Hexerpowers <hexerpowers@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/af/1d/51331e0d76a37c3eb51451603cebf87d55e041dc32befbe1cc51f19f1262/openlog-2.0.0.tar.gz",
    "platform": null,
    "description": "# OpenLog\r\n\r\nA versatile Python logging utility (overengineered python-rich wrapping) designed to enhance logging capabilities with\r\nrich console output and optional file logging.\r\n\r\n## Features\r\n\r\n- \ud83c\udfa8 **Rich Console Output**: Color-coded messages with beautiful formatting\r\n- \ud83d\udcc1 **Flexible File Logging**: Optional file output with session support\r\n- \ud83d\udd27 **Task Management**: Progress-bars, special task logging etc.\r\n- \ud83d\udcca **Multiple Log Levels**: INFO, ERROR, WARN, and INIT with distinct styling\r\n- \ud83d\udcbe **In-Memory Storage**: Retrieve and manage logs programmatically\r\n- \ud83c\udfaf **Prefix Support**: Add context to your log messages\r\n- \ud83d\udcd0 **Terminal-Aware**: Automatic width detection for optimal formatting\r\n\r\n## Installation\r\n\r\n```bash\r\npip install openlog\r\n```\r\n\r\n## Quick Start\r\n\r\n### Basic Console Logging\r\n\r\n```python\r\nfrom openlog import Logger\r\n\r\nlogger = Logger()\r\nlogger.log(\"This is an info message\")\r\nlogger.error(\"Something went wrong\")\r\nlogger.warn(\"This is a warning\")\r\nlogger.init(\"System initialized\")\r\n```\r\n\r\n### Batch Logging\r\n\r\n```python\r\n# Add multiple messages\r\n\r\nlogger.batch.add_message(\"Processing started\")\r\nlogger.batch.add_message(\"Loading configuration\")\r\nlogger.batch.add_message(\"Connecting to database\")\r\n\r\n# Log all messages in the batch\r\nlogger.flush_batch()\r\n```\r\n\r\n### File Logging\r\n\r\n```python\r\n# Basic file logging\r\nfile_logger = Logger(write_to_file=True)\r\nfile_logger.log(\"This message goes to console and file\")\r\n\r\n# Session-based logging (timestamped files)\r\nsession_logger = Logger(write_to_file=True, session=True)\r\nsession_logger.log(\"Logged with timestamp in filename\")\r\n\r\n# Organized in /logs directory\r\ndir_logger = Logger(in_dir=True, write_to_file=True)\r\ndir_logger.log(\"Logs stored in /logs directory\")\r\n```\r\n\r\n### Task Management\r\n\r\nOpenLog supports tracking long-running tasks with animated progress bars:\r\n\r\n```python\r\nlogger = Logger()\r\n\r\n# Start a task with progress bar\r\ntask_id = logger.add_task(\"Processing large dataset\")\r\n\r\n# Your long-running code here\r\n# ...\r\n\r\n# Stop the task\r\nlogger.stop_task(task_id)\r\n```\r\n\r\n#### Task Management Methods:\r\n\r\n- add_task(task_message) - Start a task with progress display\r\n- stop_task(task_id) - Stop a specific task\r\n- get_active_tasks() - Get all currently running tasks\r\n- stop_all_tasks() - Stop all active tasks (useful for cleanup)\r\n\r\n### Smart Object Formatting\r\n\r\n```python\r\n# Simple objects stay inline\r\nlogger.log({\"user\": \"Alice\", \"id\": 123})\r\n\r\n# Complex objects format vertically\r\ncomplex_data = {\r\n    \"users\": [\r\n        {\"id\": 1, \"name\": \"Alice\", \"roles\": [\"admin\", \"user\"]},\r\n        {\"id\": 2, \"name\": \"Bob\", \"roles\": [\"user\", \"viewer\"]},\r\n    ],\r\n    \"settings\": {\r\n        \"theme\": \"dark\",\r\n        \"notifications\": {\"email\": True, \"push\": False}\r\n    }\r\n}\r\nlogger.log(\"User data:\")\r\nlogger.log(complex_data)\r\n```\r\n\r\n### Retrieve Logs Programmatically\r\n\r\n```python\r\n# Get recent logs\r\nlogs = logger.flush_logs()\r\n\r\n# Get all logs from start\r\nall_logs = logger.flush_logs(from_start=True)\r\n```\r\n\r\n## Documentation\r\n\r\nFor detailed information about all features, configuration options, and advanced usage, see [FEATURES.md](FEATURES.md).\r\n\r\n## Configuration\r\n\r\n| Parameter       | Type | Default | Description                     |\r\n|-----------------|------|---------|---------------------------------|\r\n| `write_to_file` | bool | False   | Enable file logging             |\r\n| `in_dir`        | bool | False   | Store logs in `/logs` directory |\r\n| `session`       | bool | False   | Create timestamped log files    |\r\n| `prefix`        | str  | \"\"      | Add prefix to all messages      |\r\n\r\n#### Log Levels and Methods\r\n\r\n- `log()` - General information (blue)\r\n- `error()` - Error messages (red)\r\n- `warn()` - Warning messages (yellow)\r\n- `init()` - Initialization messages (purple)\r\n\r\n#### Batch Operations\r\n\r\n- `add_to_batch()` - Add message to batch\r\n- `flush_batch()` - Output all batched messages\r\n- `clear_batch()` - Clear batch without output\r\n- `batch_size()` - Get number of messages in batch\r\n\r\n#### Task Management\r\n\r\n- `add_task()` - Start task with progress bar\r\n- `stop_task()` - Stop specific task\r\n- `get_active_tasks()` - Get active task information\r\n- `stop_all_tasks()` - Stop all tasks and cleanup\r\n\r\n## Requirements\r\n\r\n- Python 3.9+\r\n- Rich library (automatically installed)\r\n\r\n## License\r\n\r\nMIT License - see [LICENSE](LICENSE) file for details.\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## Links\r\n\r\n- [GitHub Repository](https://github.com/Hexerpowers/openlog)\r\n- [Detailed Features Documentation](FEATURES.md)\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Open-source minimal Rich-based logging solution",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/Hexerpowers/openlog"
    },
    "split_keywords": [
        "logs",
        " file-logging"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "750110d3fb0c5438d52d662ed5375fc573801d9f150c25bb822c85d1f3991601",
                "md5": "d8a106a580fdcee94ee1372c505d2dea",
                "sha256": "28932c2959e6043822df5d942040100857881f9d7c88bff3fd1f2db83c9366e8"
            },
            "downloads": -1,
            "filename": "openlog-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d8a106a580fdcee94ee1372c505d2dea",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 14793,
            "upload_time": "2025-08-10T15:07:24",
            "upload_time_iso_8601": "2025-08-10T15:07:24.037331Z",
            "url": "https://files.pythonhosted.org/packages/75/01/10d3fb0c5438d52d662ed5375fc573801d9f150c25bb822c85d1f3991601/openlog-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "af1d51331e0d76a37c3eb51451603cebf87d55e041dc32befbe1cc51f19f1262",
                "md5": "91597292fbec7beb3d4c27689364b512",
                "sha256": "5f0ce4fc1e1e96f3e7bc8f00422bc6977fcf0975168f8b73b75f738a9931e4ca"
            },
            "downloads": -1,
            "filename": "openlog-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "91597292fbec7beb3d4c27689364b512",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 15904,
            "upload_time": "2025-08-10T15:07:25",
            "upload_time_iso_8601": "2025-08-10T15:07:25.331144Z",
            "url": "https://files.pythonhosted.org/packages/af/1d/51331e0d76a37c3eb51451603cebf87d55e041dc32befbe1cc51f19f1262/openlog-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-10 15:07:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Hexerpowers",
    "github_project": "openlog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "openlog"
}
        
Elapsed time: 1.75581s