log78


Namelog78 JSON
Version 2.1.3 PyPI version JSON
download
home_pagehttps://github.com/www778878net/Log78
SummaryA flexible Python logging library supporting console, file, and server logging.
upload_time2024-11-06 10:50:43
maintainerNone
docs_urlNone
authorFrieda.Hu
requires_python<4.0,>=3.9
licenseApache-2.0
keywords logging debug development
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Log78

Log78 is a flexible Python logging library that supports console, file, and server logging.

## Installation

Install Log78 using pip:

```
pip install log78
```

## Quick Start

Log78 provides two ways to log messages: a simple method for quick logging and a more detailed method using `LogEntry` objects. Here's how to get started with the simple method:

```python
from log78 import Log78

# Get the Log78 instance - no setup required!
log = Logger78.instance()

# Log a simple message
await log.INFO("Hello, Log78!")

# Log with a summary and custom level
await log.WARN("This is a warning", "Warning Summary", 60)
```

For more detailed logging, you can use the `LogEntry` object:

```python
from log78 import LogEntry, BasicInfo

log_entry = LogEntry(basic=BasicInfo(message="Detailed log message", summary="Log Summary"))
await log.INFO(log_entry)
```

Both methods are ready to use out of the box with default console and file logging.

## Advanced Configuration (Optional)

If you need custom logging behavior, you can use the `setup` method:

```python
from log78 import Logger78. ServerLog78, FileLog78, ConsoleLog78

# Create custom logger instances if needed
server_logger = ServerLog78()
file_logger = FileLog78("custom_logfile")
console_logger = ConsoleLog78()

# Setup custom loggers
log = Logger78.instance()
log.setup(server_logger, file_logger, console_logger)
```

## Properties

- `debug_kind`: A set of log debugging keywords used to control which types of logs are recorded.
- `level_file`, `level_console`, `level_api`: Respectively represent the threshold levels for file logs, console logs, and API logs.
- `debug_entry`: Used to set more fine-grained debugging conditions.

## Suggested Log Levels

- DEBUG (10): Detailed debug information, typically used only in development environments
- INFO (30): General information, can be used to track normal application operations
- WARN (50): Warning information, indicating potential issues but not affecting main functionality
- ERROR (60): Errors and serious problems that require immediate attention

## Example: Adjusting Log Levels

```python
from log78 import Logger78. LogEntry, BasicInfo

log = Logger78.instance()

# Adjust console log level to 0 to print all logs (for debugging)
log.level_console = 0
# Adjust file log level to 60 to only record more severe warnings and errors
log.level_file = 60

# Using different levels to record logs
log_entry = LogEntry(basic=BasicInfo(message="Debug information"))
await log.DEBUG(log_entry)  # Will only output to console

log_entry.basic.message = "General information"
await log.INFO(log_entry)  # Will output to console, not recorded in file

log_entry.basic.message = "Warning"
await log.WARN(log_entry)  # Will be recorded in both console and file

log_entry.basic.message = "Error"
await log.ERROR(log_entry)  # Will be recorded in console, file, and API
```

## Methods

- `DEBUG`, `INFO`, `WARN`, `ERROR`: Record logs of different levels.
- `ERROR(Exception, LogEntry)`: Records exception error logs.

## Using the LogEntry Class

The `LogEntry` class provides structured information for detailed logging:

```python
from log78 import Logger78. LogEntry, BasicInfo, EventInfo, HttpInfo

log_entry = LogEntry()
log_entry.basic = BasicInfo(
    summary="User login successful",
    log_level_number=30,
    log_level="INFO",
    message="User johndoe successfully logged into the system",
    service_name="AuthService",
    user_id="user123",
    user_name="johndoe"
)

log_entry.event = EventInfo(
    event_category="authentication",
    event_action="login",
    event_outcome="success"
)

log_entry.http = HttpInfo(
    http_request_method="POST",
    http_request_body_content="{\"username\":\"johndoe\",\"password\":\"*****\"}",
    http_response_status_code=200,
    url_original="https://api.example.com/login"
)

# Add custom properties
log_entry.add_property("customField", "customValue")

await log.INFO(log_entry)
```

## Other

For more detailed information, please refer to the project's [GitHub repository](https://github.com/www778878net/Log78) or the [API documentation](http://www.778878.net/docs/#/Log78/).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/www778878net/Log78",
    "name": "log78",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "logging, debug, development",
    "author": "Frieda.Hu",
    "author_email": "www778878net@189.cn",
    "download_url": "https://files.pythonhosted.org/packages/4d/52/5d5a32a989c325151034acdc5d8d8c0888d9ab22813901e65603482e74f1/log78-2.1.3.tar.gz",
    "platform": null,
    "description": "# Log78\n\nLog78 is a flexible Python logging library that supports console, file, and server logging.\n\n## Installation\n\nInstall Log78 using pip:\n\n```\npip install log78\n```\n\n## Quick Start\n\nLog78 provides two ways to log messages: a simple method for quick logging and a more detailed method using `LogEntry` objects. Here's how to get started with the simple method:\n\n```python\nfrom log78 import Log78\n\n# Get the Log78 instance - no setup required!\nlog = Logger78.instance()\n\n# Log a simple message\nawait log.INFO(\"Hello, Log78!\")\n\n# Log with a summary and custom level\nawait log.WARN(\"This is a warning\", \"Warning Summary\", 60)\n```\n\nFor more detailed logging, you can use the `LogEntry` object:\n\n```python\nfrom log78 import LogEntry, BasicInfo\n\nlog_entry = LogEntry(basic=BasicInfo(message=\"Detailed log message\", summary=\"Log Summary\"))\nawait log.INFO(log_entry)\n```\n\nBoth methods are ready to use out of the box with default console and file logging.\n\n## Advanced Configuration (Optional)\n\nIf you need custom logging behavior, you can use the `setup` method:\n\n```python\nfrom log78 import Logger78. ServerLog78, FileLog78, ConsoleLog78\n\n# Create custom logger instances if needed\nserver_logger = ServerLog78()\nfile_logger = FileLog78(\"custom_logfile\")\nconsole_logger = ConsoleLog78()\n\n# Setup custom loggers\nlog = Logger78.instance()\nlog.setup(server_logger, file_logger, console_logger)\n```\n\n## Properties\n\n- `debug_kind`: A set of log debugging keywords used to control which types of logs are recorded.\n- `level_file`, `level_console`, `level_api`: Respectively represent the threshold levels for file logs, console logs, and API logs.\n- `debug_entry`: Used to set more fine-grained debugging conditions.\n\n## Suggested Log Levels\n\n- DEBUG (10): Detailed debug information, typically used only in development environments\n- INFO (30): General information, can be used to track normal application operations\n- WARN (50): Warning information, indicating potential issues but not affecting main functionality\n- ERROR (60): Errors and serious problems that require immediate attention\n\n## Example: Adjusting Log Levels\n\n```python\nfrom log78 import Logger78. LogEntry, BasicInfo\n\nlog = Logger78.instance()\n\n# Adjust console log level to 0 to print all logs (for debugging)\nlog.level_console = 0\n# Adjust file log level to 60 to only record more severe warnings and errors\nlog.level_file = 60\n\n# Using different levels to record logs\nlog_entry = LogEntry(basic=BasicInfo(message=\"Debug information\"))\nawait log.DEBUG(log_entry)  # Will only output to console\n\nlog_entry.basic.message = \"General information\"\nawait log.INFO(log_entry)  # Will output to console, not recorded in file\n\nlog_entry.basic.message = \"Warning\"\nawait log.WARN(log_entry)  # Will be recorded in both console and file\n\nlog_entry.basic.message = \"Error\"\nawait log.ERROR(log_entry)  # Will be recorded in console, file, and API\n```\n\n## Methods\n\n- `DEBUG`, `INFO`, `WARN`, `ERROR`: Record logs of different levels.\n- `ERROR(Exception, LogEntry)`: Records exception error logs.\n\n## Using the LogEntry Class\n\nThe `LogEntry` class provides structured information for detailed logging:\n\n```python\nfrom log78 import Logger78. LogEntry, BasicInfo, EventInfo, HttpInfo\n\nlog_entry = LogEntry()\nlog_entry.basic = BasicInfo(\n    summary=\"User login successful\",\n    log_level_number=30,\n    log_level=\"INFO\",\n    message=\"User johndoe successfully logged into the system\",\n    service_name=\"AuthService\",\n    user_id=\"user123\",\n    user_name=\"johndoe\"\n)\n\nlog_entry.event = EventInfo(\n    event_category=\"authentication\",\n    event_action=\"login\",\n    event_outcome=\"success\"\n)\n\nlog_entry.http = HttpInfo(\n    http_request_method=\"POST\",\n    http_request_body_content=\"{\\\"username\\\":\\\"johndoe\\\",\\\"password\\\":\\\"*****\\\"}\",\n    http_response_status_code=200,\n    url_original=\"https://api.example.com/login\"\n)\n\n# Add custom properties\nlog_entry.add_property(\"customField\", \"customValue\")\n\nawait log.INFO(log_entry)\n```\n\n## Other\n\nFor more detailed information, please refer to the project's [GitHub repository](https://github.com/www778878net/Log78) or the [API documentation](http://www.778878.net/docs/#/Log78/).\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A flexible Python logging library supporting console, file, and server logging.",
    "version": "2.1.3",
    "project_urls": {
        "Documentation": "https://github.com/www778878net/Log78",
        "Homepage": "https://github.com/www778878net/Log78",
        "Repository": "https://github.com/www778878net/Log78.git"
    },
    "split_keywords": [
        "logging",
        " debug",
        " development"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7324ac23aa8b55d70ab45c04fa30017bfe05287d274ed3d5ec62211a05151bf6",
                "md5": "2db3432899275326fcbd943bffe2282f",
                "sha256": "eaf88ddd4f1c676dee2682a0d646086c26ea2fcebb691988bd7126bbee3ebbd8"
            },
            "downloads": -1,
            "filename": "log78-2.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2db3432899275326fcbd943bffe2282f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 18598,
            "upload_time": "2024-11-06T10:50:41",
            "upload_time_iso_8601": "2024-11-06T10:50:41.900355Z",
            "url": "https://files.pythonhosted.org/packages/73/24/ac23aa8b55d70ab45c04fa30017bfe05287d274ed3d5ec62211a05151bf6/log78-2.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d525d5a32a989c325151034acdc5d8d8c0888d9ab22813901e65603482e74f1",
                "md5": "8ca46bb1667a18043fc21865fb815665",
                "sha256": "622dc2cb4f34ba803a572956eb554e04895d8aa48b8d9a3f5a7f69605e40b5bc"
            },
            "downloads": -1,
            "filename": "log78-2.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "8ca46bb1667a18043fc21865fb815665",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 16039,
            "upload_time": "2024-11-06T10:50:43",
            "upload_time_iso_8601": "2024-11-06T10:50:43.786202Z",
            "url": "https://files.pythonhosted.org/packages/4d/52/5d5a32a989c325151034acdc5d8d8c0888d9ab22813901e65603482e74f1/log78-2.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-06 10:50:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "www778878net",
    "github_project": "Log78",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "log78"
}
        
Elapsed time: 0.34666s