oshtools


Nameoshtools JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryA simple Python logging library for chat applications
upload_time2025-07-24 05:52:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords llm chat logging gcp google-cloud logger
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OSH Logger

A simple Python logging library for chat applications, with support for both
local development and Google Cloud Platform (GCP) environments.

## Features

- **Dual Environment Support**: Automatically detects and configures logging for
  local development and GCP environments
- **Colored Local Output**: Beautiful, colored terminal output with proper text
  wrapping in local development environment
- **Structured GCP Logging**: Labelled logs and structured output on GCP, with ability to filter by a Logger instance's name
- **Thread-Safe**: Supports logging with thread IDs for concurrent applications
- **Configurable Timestamps**: Enable/disable timestamps as needed

## Installation

### Basic Installation

```bash
pip install oshtools
```

### With Google Cloud Support

```bash
pip install oshtools[gcp]
```

## Quick Start

```python
from osh import Logger

# Create a separate logger instance for each module
logger = Logger("main")

# Pass in a thread ID to the contructor
# The thread ID is a unique identifier that can help trace requests on GCP
logger = Logger("utils", "123")

# Basic logging
logger.log("Application started")
logger.info("Processing complete")
logger.debug("Debug information")
logger.warn("Warning message")
logger.error("Error occurred")

# Log and add a thread ID dynamically
logger.log("Processing request", thread_id="thread-123")

# Structured logging (useful for GCP)
logger.struct_log("User action", user_id="123", action="login", level=logging.INFO)
```

## Environment Detection

The logger automatically detects the environment:

- **GCP Environment**: Detected by presence of `K_SERVICE` or
  `GOOGLE_CLOUD_PROJECT` environment variables
- **Local Environment**: Uses colored terminal output with proper formatting

## Log Types

The logger supports several log types with different colors and levels:

- `log()` - General information (cyan)
- `info()` - Informational messages (blue)
- `runtime()` - Runtime information (bright magenta)
- `think()` - Thinking/processing logs (light blue)
- `debug()` - Debug information (green)
- `warn()` - Warnings (yellow)
- `error()` - Errors (red)
- `critical()` - Critical errors (bright red)

## Configuration

### Timestamps

```python
logger = Logger("my-app")
logger.set_timestamps(False)  # Disable timestamps
logger.set_timestamps(True)   # Enable timestamps
```

### Log Levels

```python
import logging
logger = Logger("my-app", level=logging.DEBUG)
```

## Google Cloud Platform Integration

When running in GCP (Cloud Run, App Engine, etc.), the logger automatically:

- Uses Google Cloud Logging handlers
- Adds structured metadata and labels
- Includes logger names and thread IDs in labels
- Maintains local CLI formatting for debugging

## Requirements

- Python 3.8+
- `google-cloud-logging` (optional, for GCP support)

## License

MIT License

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "oshtools",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "llm, chat, logging, gcp, google-cloud, logger",
    "author": null,
    "author_email": "zion <atibjawad@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/42/82/494268d5ac67051b7aa04a26746a5c594209212622b189ec5fc4772632f2/oshtools-0.1.0.tar.gz",
    "platform": null,
    "description": "# OSH Logger\n\nA simple Python logging library for chat applications, with support for both\nlocal development and Google Cloud Platform (GCP) environments.\n\n## Features\n\n- **Dual Environment Support**: Automatically detects and configures logging for\n  local development and GCP environments\n- **Colored Local Output**: Beautiful, colored terminal output with proper text\n  wrapping in local development environment\n- **Structured GCP Logging**: Labelled logs and structured output on GCP, with ability to filter by a Logger instance's name\n- **Thread-Safe**: Supports logging with thread IDs for concurrent applications\n- **Configurable Timestamps**: Enable/disable timestamps as needed\n\n## Installation\n\n### Basic Installation\n\n```bash\npip install oshtools\n```\n\n### With Google Cloud Support\n\n```bash\npip install oshtools[gcp]\n```\n\n## Quick Start\n\n```python\nfrom osh import Logger\n\n# Create a separate logger instance for each module\nlogger = Logger(\"main\")\n\n# Pass in a thread ID to the contructor\n# The thread ID is a unique identifier that can help trace requests on GCP\nlogger = Logger(\"utils\", \"123\")\n\n# Basic logging\nlogger.log(\"Application started\")\nlogger.info(\"Processing complete\")\nlogger.debug(\"Debug information\")\nlogger.warn(\"Warning message\")\nlogger.error(\"Error occurred\")\n\n# Log and add a thread ID dynamically\nlogger.log(\"Processing request\", thread_id=\"thread-123\")\n\n# Structured logging (useful for GCP)\nlogger.struct_log(\"User action\", user_id=\"123\", action=\"login\", level=logging.INFO)\n```\n\n## Environment Detection\n\nThe logger automatically detects the environment:\n\n- **GCP Environment**: Detected by presence of `K_SERVICE` or\n  `GOOGLE_CLOUD_PROJECT` environment variables\n- **Local Environment**: Uses colored terminal output with proper formatting\n\n## Log Types\n\nThe logger supports several log types with different colors and levels:\n\n- `log()` - General information (cyan)\n- `info()` - Informational messages (blue)\n- `runtime()` - Runtime information (bright magenta)\n- `think()` - Thinking/processing logs (light blue)\n- `debug()` - Debug information (green)\n- `warn()` - Warnings (yellow)\n- `error()` - Errors (red)\n- `critical()` - Critical errors (bright red)\n\n## Configuration\n\n### Timestamps\n\n```python\nlogger = Logger(\"my-app\")\nlogger.set_timestamps(False)  # Disable timestamps\nlogger.set_timestamps(True)   # Enable timestamps\n```\n\n### Log Levels\n\n```python\nimport logging\nlogger = Logger(\"my-app\", level=logging.DEBUG)\n```\n\n## Google Cloud Platform Integration\n\nWhen running in GCP (Cloud Run, App Engine, etc.), the logger automatically:\n\n- Uses Google Cloud Logging handlers\n- Adds structured metadata and labels\n- Includes logger names and thread IDs in labels\n- Maintains local CLI formatting for debugging\n\n## Requirements\n\n- Python 3.8+\n- `google-cloud-logging` (optional, for GCP support)\n\n## License\n\nMIT License\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple Python logging library for chat applications",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/zion-off/oshtools",
        "Issues": "https://github.com/zion-off/oshtools/issues",
        "Repository": "https://github.com/zion-off/oshtools"
    },
    "split_keywords": [
        "llm",
        " chat",
        " logging",
        " gcp",
        " google-cloud",
        " logger"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6511f56ce5ac0a14dd9d39614e040bae35507afcfe3ec9851791953f23896d00",
                "md5": "49b80e9d152b955625b5cd18cf35fc37",
                "sha256": "4a7a938bc32d00477a8e093856709ca328b3035bb9c5cef63ca0a19c378e9238"
            },
            "downloads": -1,
            "filename": "oshtools-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "49b80e9d152b955625b5cd18cf35fc37",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7500,
            "upload_time": "2025-07-24T05:52:03",
            "upload_time_iso_8601": "2025-07-24T05:52:03.012751Z",
            "url": "https://files.pythonhosted.org/packages/65/11/f56ce5ac0a14dd9d39614e040bae35507afcfe3ec9851791953f23896d00/oshtools-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4282494268d5ac67051b7aa04a26746a5c594209212622b189ec5fc4772632f2",
                "md5": "a3c0c34a5c6c08c786a0fa387806ca8c",
                "sha256": "bfa2df030f39d1fe3b28d373cb2781b8d9a003183b99836ae563c0f21f2bb453"
            },
            "downloads": -1,
            "filename": "oshtools-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a3c0c34a5c6c08c786a0fa387806ca8c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8871,
            "upload_time": "2025-07-24T05:52:04",
            "upload_time_iso_8601": "2025-07-24T05:52:04.413593Z",
            "url": "https://files.pythonhosted.org/packages/42/82/494268d5ac67051b7aa04a26746a5c594209212622b189ec5fc4772632f2/oshtools-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-24 05:52:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zion-off",
    "github_project": "oshtools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "oshtools"
}
        
Elapsed time: 0.40900s