setlogging


Namesetlogging JSON
Version 0.4.3 PyPI version JSON
download
home_pageNone
SummaryA flexible logging utility with JSON support and timezone awareness
upload_time2025-02-21 04:28:32
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
├── 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/69/2589cc5773b782cee98d5058bfc655c2b4ab1235df574904548d8a26dd3c/setlogging-0.4.3.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 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.4.3",
    "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": "c586d3efab086339e93f3229cb403d6aa7a89f2971e9ff34411a2bd181ea3106",
                "md5": "9bbf6ccbe2466d7ff878633c367f052d",
                "sha256": "0a1c42a8c57637071b8962d16ad24dfbd00c6e8f44828c586ddbfe22ac25d95d"
            },
            "downloads": -1,
            "filename": "setlogging-0.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9bbf6ccbe2466d7ff878633c367f052d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 6571,
            "upload_time": "2025-02-21T04:28:30",
            "upload_time_iso_8601": "2025-02-21T04:28:30.423375Z",
            "url": "https://files.pythonhosted.org/packages/c5/86/d3efab086339e93f3229cb403d6aa7a89f2971e9ff34411a2bd181ea3106/setlogging-0.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d9692589cc5773b782cee98d5058bfc655c2b4ab1235df574904548d8a26dd3c",
                "md5": "59dcd6994ec1655f68384582f62079a3",
                "sha256": "0422b0a5fd32b5661fd0a1ace29d564664279e0f01bae232cdbb00210ac2a316"
            },
            "downloads": -1,
            "filename": "setlogging-0.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "59dcd6994ec1655f68384582f62079a3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 6038,
            "upload_time": "2025-02-21T04:28:32",
            "upload_time_iso_8601": "2025-02-21T04:28:32.032528Z",
            "url": "https://files.pythonhosted.org/packages/d9/69/2589cc5773b782cee98d5058bfc655c2b4ab1235df574904548d8a26dd3c/setlogging-0.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-21 04:28:32",
    "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: 1.58533s