dm-logger


Namedm-logger JSON
Version 0.5.2 PyPI version JSON
download
home_pagehttps://pypi.org/project/dm-logger
SummaryThis is my custom logger
upload_time2024-02-01 16:26:03
maintainer
docs_urlNone
authordimka4621
requires_python>=3.8
license
keywords dm logger
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # DM-Logger

## Urls

* [PyPI](https://pypi.org/project/dm-logger/)
* [GitHub](https://github.com/DIMKA4621/dm-logger)

## Parameters

### _Options for creating individual loggers_

| Parameter    | Type   | Default Value | Description                                 |
|--------------|--------|---------------|---------------------------------------------|
| `name`       | `str`  | (required)    | The name associated with the class instance |
| `level`      | `str`  | `"DEBUG"`     | The logging level (e.g., "DEBUG", "INFO")   |
| `write_logs` | `bool` | `True`        | Whether to write logs to a file             |
| `print_logs` | `bool` | `True`        | Whether to print logs to the console        |
| `file_name`  | `str`  | `None`        | The name of the log file                    |

### _Common class parameters for all loggers_

| Parameter             | Type             | Default Value  | Description                                          |
|-----------------------|------------------|----------------|------------------------------------------------------|
| `logs_dir_path`       | `str`            | `"logs"`       | Path to the directory where the logs will be stored  |
| `file_name`           | `str`            | `"main.log"`   | The name of the log file                             |
| `write_mode`          | `"a" \| "w"`     | `"w"`          | File write mode ('a' for append, 'w' for overwrite)  |
| `max_MB`              | `int`            | `5`            | Maximum size of the log file in MB                   |
| `max_count`           | `int`            | `10`           | Maximum number of log files                          |
| `show_name_label`     | `bool`           | `True`         | Whether to display the name label in log entries     |
| `show_location_label` | `bool \| "auto"` | `"auto"`       | Whether to display the location label in log entries |
| `format_string`       | `str`            | `None`         | The format string of the log                         |

## Usage

### Setup class config

_This config usage for all loggers_

```python
from dm_logger import DMLogger

DMLogger.config.show_name_label = False
DMLogger.config.max_count = 5
```

### Record

```python
from dm_logger import DMLogger

logger = DMLogger("main")

logger.info("test message", tag="test tag")
logger.debug("new message", id=123312)
logger.info("only mess")
logger.critical(env="production")
logger.warning({"key": "value"})
logger.error(["item1", "item2", 3])
logger.info()
```

Output

```textmate
19-11-2023 00:49:03.406 [INFO] {tag: 'test tag'} -- test message
19-11-2023 00:49:03.406 [DEBUG] {id: 123312} -- new message
19-11-2023 00:49:03.407 [INFO] -- only mess
19-11-2023 00:49:03.407 [CRITICAL] (test.<module>:8) {env: 'production'}
19-11-2023 00:49:03.408 [WARNING] -- {'key': 'value'}
19-11-2023 00:49:03.408 [ERROR] (test.<module>:10) -- ['item1', 'item2', 3]
19-11-2023 00:49:03.409 [INFO]
```

### Several loggers

_All loggers will write to one file_

```python
from dm_logger import DMLogger

logger = DMLogger("main", level="INFO")
logger2 = DMLogger("only_file", print_logs=False)

logger.info("Start app")
logger2.debug(process_id=123123)
logger.error("App crashed!")
```

Output

```textmate
19-11-2023 00:56:36.879 [INFO] [main] -- Start app
19-11-2023 00:56:36.880 [ERROR] [main] (test.<module>:10) -- App crashed!
```

Log file

```textmate
19-11-2023 00:56:36.879 [INFO] [main] -- Start app
19-11-2023 00:56:36.880 [DEBUG] [only_file] {process_id: 123123}
19-11-2023 00:56:36.880 [ERROR] [main] (test.<module>:10) -- App crashed!
```

## Requirements

Python 3.8 or higher.

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/dm-logger",
    "name": "dm-logger",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "dm logger",
    "author": "dimka4621",
    "author_email": "mismartconfig@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ef/49/2b72c8969666bafa291ba650ccdaaaed85c31a426e138da30e8300685cd3/dm-logger-0.5.2.tar.gz",
    "platform": null,
    "description": "# DM-Logger\n\n## Urls\n\n* [PyPI](https://pypi.org/project/dm-logger/)\n* [GitHub](https://github.com/DIMKA4621/dm-logger)\n\n## Parameters\n\n### _Options for creating individual loggers_\n\n| Parameter    | Type   | Default Value | Description                                 |\n|--------------|--------|---------------|---------------------------------------------|\n| `name`       | `str`  | (required)    | The name associated with the class instance |\n| `level`      | `str`  | `\"DEBUG\"`     | The logging level (e.g., \"DEBUG\", \"INFO\")   |\n| `write_logs` | `bool` | `True`        | Whether to write logs to a file             |\n| `print_logs` | `bool` | `True`        | Whether to print logs to the console        |\n| `file_name`  | `str`  | `None`        | The name of the log file                    |\n\n### _Common class parameters for all loggers_\n\n| Parameter             | Type             | Default Value  | Description                                          |\n|-----------------------|------------------|----------------|------------------------------------------------------|\n| `logs_dir_path`       | `str`            | `\"logs\"`       | Path to the directory where the logs will be stored  |\n| `file_name`           | `str`            | `\"main.log\"`   | The name of the log file                             |\n| `write_mode`          | `\"a\" \\| \"w\"`     | `\"w\"`          | File write mode ('a' for append, 'w' for overwrite)  |\n| `max_MB`              | `int`            | `5`            | Maximum size of the log file in MB                   |\n| `max_count`           | `int`            | `10`           | Maximum number of log files                          |\n| `show_name_label`     | `bool`           | `True`         | Whether to display the name label in log entries     |\n| `show_location_label` | `bool \\| \"auto\"` | `\"auto\"`       | Whether to display the location label in log entries |\n| `format_string`       | `str`            | `None`         | The format string of the log                         |\n\n## Usage\n\n### Setup class config\n\n_This config usage for all loggers_\n\n```python\nfrom dm_logger import DMLogger\n\nDMLogger.config.show_name_label = False\nDMLogger.config.max_count = 5\n```\n\n### Record\n\n```python\nfrom dm_logger import DMLogger\n\nlogger = DMLogger(\"main\")\n\nlogger.info(\"test message\", tag=\"test tag\")\nlogger.debug(\"new message\", id=123312)\nlogger.info(\"only mess\")\nlogger.critical(env=\"production\")\nlogger.warning({\"key\": \"value\"})\nlogger.error([\"item1\", \"item2\", 3])\nlogger.info()\n```\n\nOutput\n\n```textmate\n19-11-2023 00:49:03.406 [INFO] {tag: 'test tag'} -- test message\n19-11-2023 00:49:03.406 [DEBUG] {id: 123312} -- new message\n19-11-2023 00:49:03.407 [INFO] -- only mess\n19-11-2023 00:49:03.407 [CRITICAL] (test.<module>:8) {env: 'production'}\n19-11-2023 00:49:03.408 [WARNING] -- {'key': 'value'}\n19-11-2023 00:49:03.408 [ERROR] (test.<module>:10) -- ['item1', 'item2', 3]\n19-11-2023 00:49:03.409 [INFO]\n```\n\n### Several loggers\n\n_All loggers will write to one file_\n\n```python\nfrom dm_logger import DMLogger\n\nlogger = DMLogger(\"main\", level=\"INFO\")\nlogger2 = DMLogger(\"only_file\", print_logs=False)\n\nlogger.info(\"Start app\")\nlogger2.debug(process_id=123123)\nlogger.error(\"App crashed!\")\n```\n\nOutput\n\n```textmate\n19-11-2023 00:56:36.879 [INFO] [main] -- Start app\n19-11-2023 00:56:36.880 [ERROR] [main] (test.<module>:10) -- App crashed!\n```\n\nLog file\n\n```textmate\n19-11-2023 00:56:36.879 [INFO] [main] -- Start app\n19-11-2023 00:56:36.880 [DEBUG] [only_file] {process_id: 123123}\n19-11-2023 00:56:36.880 [ERROR] [main] (test.<module>:10) -- App crashed!\n```\n\n## Requirements\n\nPython 3.8 or higher.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "This is my custom logger",
    "version": "0.5.2",
    "project_urls": {
        "GitHub": "https://github.com/DIMKA4621/dm-logger",
        "Homepage": "https://pypi.org/project/dm-logger"
    },
    "split_keywords": [
        "dm",
        "logger"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bceef852619f60a5f23385912134e0954d07fcfccaaf9bca493ecc8fbed57632",
                "md5": "51d2be984caad7adf8d62617e180ec1f",
                "sha256": "997672b708b471f838d2d75c5037f7891d287a576c4dacb29ba413eeca17a818"
            },
            "downloads": -1,
            "filename": "dm_logger-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "51d2be984caad7adf8d62617e180ec1f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5935,
            "upload_time": "2024-02-01T16:26:02",
            "upload_time_iso_8601": "2024-02-01T16:26:02.051389Z",
            "url": "https://files.pythonhosted.org/packages/bc/ee/f852619f60a5f23385912134e0954d07fcfccaaf9bca493ecc8fbed57632/dm_logger-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef492b72c8969666bafa291ba650ccdaaaed85c31a426e138da30e8300685cd3",
                "md5": "acbe698c477378ca576e2d4663e004e9",
                "sha256": "e653e418df29d06d623df81590185e788a7f2288a16408323d11c5f5a8814bc2"
            },
            "downloads": -1,
            "filename": "dm-logger-0.5.2.tar.gz",
            "has_sig": false,
            "md5_digest": "acbe698c477378ca576e2d4663e004e9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4654,
            "upload_time": "2024-02-01T16:26:03",
            "upload_time_iso_8601": "2024-02-01T16:26:03.126740Z",
            "url": "https://files.pythonhosted.org/packages/ef/49/2b72c8969666bafa291ba650ccdaaaed85c31a426e138da30e8300685cd3/dm-logger-0.5.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-01 16:26:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DIMKA4621",
    "github_project": "dm-logger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dm-logger"
}
        
Elapsed time: 0.31013s