oshtools


Nameoshtools JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryA simple Python logging library for chat applications
upload_time2025-09-13 23:43:09
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/67/b5/9c092cc71b716a846be24d7c05dac1530e98b8ee0264a6926782db675964/oshtools-0.1.4.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.4",
    "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": "9f74f74b48ba7a81c5c0f9e34d7e349861d781928257d907df226f3ee896e81c",
                "md5": "271c0c0b51ab8536e33ff055cd1c40a6",
                "sha256": "f6bd4e81a7ab68b43859862e7132858fe2ddff47ef4ee7e0fcd175b98d6629f3"
            },
            "downloads": -1,
            "filename": "oshtools-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "271c0c0b51ab8536e33ff055cd1c40a6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8754,
            "upload_time": "2025-09-13T23:43:07",
            "upload_time_iso_8601": "2025-09-13T23:43:07.584196Z",
            "url": "https://files.pythonhosted.org/packages/9f/74/f74b48ba7a81c5c0f9e34d7e349861d781928257d907df226f3ee896e81c/oshtools-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "67b59c092cc71b716a846be24d7c05dac1530e98b8ee0264a6926782db675964",
                "md5": "09eb57359519598a6e757eca0df37ba1",
                "sha256": "f4699532c3cb2d3357443f593ca0ae645fe8d1f87476668a11e35fce273f65f0"
            },
            "downloads": -1,
            "filename": "oshtools-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "09eb57359519598a6e757eca0df37ba1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9982,
            "upload_time": "2025-09-13T23:43:09",
            "upload_time_iso_8601": "2025-09-13T23:43:09.062867Z",
            "url": "https://files.pythonhosted.org/packages/67/b5/9c092cc71b716a846be24d7c05dac1530e98b8ee0264a6926782db675964/oshtools-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-13 23:43:09",
    "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: 1.29064s