setlogging


Namesetlogging JSON
Version 0.3.5 PyPI version JSON
download
home_pageNone
SummaryA flexible logging utility with JSON support and timezone awareness
upload_time2025-02-01 02:12:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords json logging timezone
VCS
bugtrack_url
requirements pytest pytest-cov semantic-release flake8 black
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Setlogging

[![Python](https://img.shields.io/badge/Python-3.7+-blue.svg)](https://www.python.org/downloads/)
[![PyPI version](https://badge.fury.io/py/setlogging.svg)](https://badge.fury.io/py/setlogging)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A flexible Python logging utility with JSON support and timezone awareness.

## Author

- **Name:** Jie Yan
- **Contact:** <kiki3890528@gmail.com>

## Features

- JSON and plain text log formats
- Log file rotation with size limits
- Console and logfile output options
- Timezone-aware logging
- Customizable formatting
- Type-safe configuration

## Installation

```bash
pip install setlogging
```

## Usage

```python
from setlogging import get_logger

# Basic logging
logger = get_logger()
logger.info("Basic log message")

# JSON logging with indentation
logger = get_logger(json_format=True, indent=2)
logger.info("Structured logging")

# Custom file and rotation
logger = get_logger(
    log_file="/tmp/app.log",
    max_size_mb=10,  # 10MB
    backup_count=5
)

# Disable console output with log file
logger = get_logger(console_output=False, logfile="./logs/app.log")
logger.info("This will not be printed to the console")
```

## Project Structure

```
setlogging/
├── src/
│   └── setlogging/
│       ├── __init__.py
│       └── logger.py
├── tests/
│   ├── __init__.py
│   └── test_logger.py
├── pyproject.toml
├── README.md
└── LICENSE
```

## Configuration Options

| Option          | Type    | Default                        | Description                             |
|-----------------|---------|--------------------------------|-----------------------------------------|
| `log_level`     | int     | `DEBUG`                        | Logging level                           |
| `log_file`      | str     | `False`          | Log file path                           |
| `max_size_mb`   | int     | `25`                           | Max file size in MB before rotation     |
| `backup_count`  | int     | `7`                            | Number of backup files                  |
| `console_output`| bool    | `True`                         | Enable console logging                  |
| `log_format`    | str     | `None`                         | Custom log format string                |
| `date_format`   | str     | `None`                         | Custom date format string               |
| `json_format`   | bool    | `False`                        | Enable JSON formatting                  |
| `indent`        | int     | `None`                         | JSON indentation level                  |

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "setlogging",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "json, logging, timezone",
    "author": null,
    "author_email": "Jie Yan <kiki3890528@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d9/95/fd6d335f94387b4c918f3e95a1f62a1d67c3ba52e9e3d7ccd568e11b5c08/setlogging-0.3.5.tar.gz",
    "platform": null,
    "description": "# Setlogging\n\n[![Python](https://img.shields.io/badge/Python-3.7+-blue.svg)](https://www.python.org/downloads/)\n[![PyPI version](https://badge.fury.io/py/setlogging.svg)](https://badge.fury.io/py/setlogging)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA flexible Python logging utility with JSON support and timezone awareness.\n\n## Author\n\n- **Name:** Jie Yan\n- **Contact:** <kiki3890528@gmail.com>\n\n## Features\n\n- JSON and plain text log formats\n- Log file rotation with size limits\n- Console and logfile output options\n- Timezone-aware logging\n- Customizable formatting\n- Type-safe configuration\n\n## Installation\n\n```bash\npip install setlogging\n```\n\n## Usage\n\n```python\nfrom setlogging import get_logger\n\n# Basic logging\nlogger = get_logger()\nlogger.info(\"Basic log message\")\n\n# JSON logging with indentation\nlogger = get_logger(json_format=True, indent=2)\nlogger.info(\"Structured logging\")\n\n# Custom file and rotation\nlogger = get_logger(\n    log_file=\"/tmp/app.log\",\n    max_size_mb=10,  # 10MB\n    backup_count=5\n)\n\n# Disable console output with log file\nlogger = get_logger(console_output=False, logfile=\"./logs/app.log\")\nlogger.info(\"This will not be printed to the console\")\n```\n\n## Project Structure\n\n```\nsetlogging/\n\u251c\u2500\u2500 src/\n\u2502   \u2514\u2500\u2500 setlogging/\n\u2502       \u251c\u2500\u2500 __init__.py\n\u2502       \u2514\u2500\u2500 logger.py\n\u251c\u2500\u2500 tests/\n\u2502   \u251c\u2500\u2500 __init__.py\n\u2502   \u2514\u2500\u2500 test_logger.py\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 README.md\n\u2514\u2500\u2500 LICENSE\n```\n\n## Configuration Options\n\n| Option          | Type    | Default                        | Description                             |\n|-----------------|---------|--------------------------------|-----------------------------------------|\n| `log_level`     | int     | `DEBUG`                        | Logging level                           |\n| `log_file`      | str     | `False`          | Log file path                           |\n| `max_size_mb`   | int     | `25`                           | Max file size in MB before rotation     |\n| `backup_count`  | int     | `7`                            | Number of backup files                  |\n| `console_output`| bool    | `True`                         | Enable console logging                  |\n| `log_format`    | str     | `None`                         | Custom log format string                |\n| `date_format`   | str     | `None`                         | Custom date format string               |\n| `json_format`   | bool    | `False`                        | Enable JSON formatting                  |\n| `indent`        | int     | `None`                         | JSON indentation level                  |\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A flexible logging utility with JSON support and timezone awareness",
    "version": "0.3.5",
    "project_urls": {
        "Homepage": "https://github.com/JieYanTIBCO/setlogging",
        "Repository": "https://github.com/JieYanTIBCO/setlogging"
    },
    "split_keywords": [
        "json",
        " logging",
        " timezone"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "863ab1aad623f78b2b119a6b0fdb2f12b6d7a3b054551a6abe0b82215be49cff",
                "md5": "d4669bc8031649519ee36fb9ed68b052",
                "sha256": "95083976908a584b88e19884e0a9062934fbf4462ca1240360ceea339397ff92"
            },
            "downloads": -1,
            "filename": "setlogging-0.3.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d4669bc8031649519ee36fb9ed68b052",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 8489,
            "upload_time": "2025-02-01T02:12:36",
            "upload_time_iso_8601": "2025-02-01T02:12:36.795033Z",
            "url": "https://files.pythonhosted.org/packages/86/3a/b1aad623f78b2b119a6b0fdb2f12b6d7a3b054551a6abe0b82215be49cff/setlogging-0.3.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d995fd6d335f94387b4c918f3e95a1f62a1d67c3ba52e9e3d7ccd568e11b5c08",
                "md5": "b63813b078a9a10eeba8d4f43d36484f",
                "sha256": "eb436828b09cdc0e534af1e6515cf33cab25f6a013410a2b0286dad6f6b6c9cd"
            },
            "downloads": -1,
            "filename": "setlogging-0.3.5.tar.gz",
            "has_sig": false,
            "md5_digest": "b63813b078a9a10eeba8d4f43d36484f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 6081,
            "upload_time": "2025-02-01T02:12:40",
            "upload_time_iso_8601": "2025-02-01T02:12:40.430955Z",
            "url": "https://files.pythonhosted.org/packages/d9/95/fd6d335f94387b4c918f3e95a1f62a1d67c3ba52e9e3d7ccd568e11b5c08/setlogging-0.3.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-01 02:12:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JieYanTIBCO",
    "github_project": "setlogging",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "pytest-cov",
            "specs": []
        },
        {
            "name": "semantic-release",
            "specs": []
        },
        {
            "name": "flake8",
            "specs": []
        },
        {
            "name": "black",
            "specs": []
        }
    ],
    "lcname": "setlogging"
}
        
Elapsed time: 0.69644s