uglylogger


Nameuglylogger JSON
Version 0.8.0 PyPI version JSON
download
home_pageNone
SummaryAn ugly, slow Logger class for python
upload_time2024-03-22 00:14:34
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT License Copyright (c) 2023 sevketcaba Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords python python3 log logger oop pretty ugly
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # uglylogger

An ugly, slow Logger class for python

## FAQ

### Why required python version is equal or greater than 3.10?  
- match .. case .. is introduced in [3.10](https://docs.python.org/3/whatsnew/3.10.html) and I am not interested in supporting older releases  

### Why is it ugly?
- I am not an expert on Python
- It is not thread-safe
- I don't know what happens if two instances are created with the same name, and I don't care. I'd never do that
- The solo purpose is to have an easy to use and easy to read logger class

### Why is it ugly but not that ugly?
- it is easy to use and easy to read
- I may keep this library up-to-date and even optimize it in the future
- at least it has a CI/CD pipeline

## Installation

`pip install uglylogger`

## Release Notes

[Release notes](RELEASE_NOTES.md)  

## Usage

### Instantiate
```
# A logger which can log both to console and to a file
logger = Logger("name", "file.log")  

# A logger which can only log to console
logger = Logger("name")  
```

### Release the resources
```
logger.release()
```
- Releases the resources, it's safe to delete the log file after calling this method

### Color Mode
```
logger.set_color_mode(LogColorMode.COLORED)
```
- coloroed output if the console/terminal supports it
```
logger.set_color_mode(LogColorMode.MONO)
```
- no color used for the console/terminal output

### Log to console
```
logger.console("Message", color=LogColor.BLACK, level=LogLevel.DEBUG)
```
- color and level are optional
- if not provided, default color is BLACK
- if not provided, default level is DEBUG

### Log to file
```
logger.file("Message", level=LogLevel.DEBUG)
```
- level is optional
- if not provided, default level is DEBUG
- if instantiated without a file name, nothing happens

### Log to both file and console
```
logger.log("Message", color=LogColor.BLACK, level=LogLevel.DEBUG, output=LogOutput.ALL)
```
- color, level and output are optional
- if not provided, default color is BLACK
- if not provided, default level is DEBUG
- if not provided, default output is ALL
- if instantiated without a file name, writing to file is ignored


### Other ways of logging

`logger.debug("Message", color=LogColor.BLACK, output=LogOutput.ALL)`  
`logger.info("Message", color=LogColor.BLACK, output=LogOutput.ALL)`  
`logger.warning("Message", color=LogColor.BLACK, output=LogOutput.ALL)`  
`logger.error("Message", color=LogColor.BLACK, output=LogOutput.ALL)`  
`logger.critical("Message", color=LogColor.BLACK, output=LogOutput.ALL)`  

### Available LogColor
    - BLACK
    - RED
    - GREEN
    - YELLOW
    - BLUE
    - MAGENTA
    - CYAN
    - WHITE

### Available LogLevel
    - DEBUG
    - INFO
    - WARNING
    - ERROR
    - CRITICAL

### Available LogOutput
    - NONE
    - CONSOLE
    - FILE
    - ALL

## set log format
```
logger.set_format([
    ...
    LogFormatBlock.XXX
    ...
])
```

### Available LogFormatBlock
    - NAME
    - LEVEL
    - DATETIME
    - MESSAGE
    - FILE
    - LINE
    - FUNCTION

### Example Formats
```
logger.set_format([LogFormatBlock.MESSAGE])
logger.console("Hello World!")
# Output : Hello World!
```
```
logger.set_format([
    "[",
    LogFormatBlock.LEVEL,
    "] ",
    LogFormatBlock.MESSAGE]
)
logger.console("Hello World!")
# Output : [DEBUG] Hello World!
```


### <a name="function_move"></a> Move the log file to another location
```
logger.move(new_file: str, option: LogMoveOption)
# Output : Hello World!
```
### Available LogMoveOption
    - MOVE_AND_APPEND  
       Moves the log file to the destination
       Deletes if there's already a file in the destination
       Appends to the moved file
       Old file is obviously deleted
    - COPY_AND_APPEND  
       Copies the log file to the destination
       Deletes if there's already a file in the destination
       Appends to the moved file
       Old file is obviously remains    
    - KEEP_AND_APPEND  
       Keeps the old log file
       Appends if there's already a file in the destination
       Creates a new file if not
    - KEEP_AND_INIT  
       Keeps the old log file
       Creates a new file in the destination    
    - DELETE_AND_INIT  
       Deletes the old log file
       Creates a new file in the destination
       

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "uglylogger",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Sevket Sureyya Caba <sevketcaba@gmail.com>",
    "keywords": "python, python3, log, logger, oop, pretty, ugly",
    "author": null,
    "author_email": "Sevket Sureyya Caba <sevketcaba@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/97/73/f790d23b35dd64aa302e04bbcdb398aeeb12070858ed7e553bc6b4d6ae14/uglylogger-0.8.0.tar.gz",
    "platform": null,
    "description": "# uglylogger\n\nAn ugly, slow Logger class for python\n\n## FAQ\n\n### Why required python version is equal or greater than 3.10?  \n- match .. case .. is introduced in [3.10](https://docs.python.org/3/whatsnew/3.10.html) and I am not interested in supporting older releases  \n\n### Why is it ugly?\n- I am not an expert on Python\n- It is not thread-safe\n- I don't know what happens if two instances are created with the same name, and I don't care. I'd never do that\n- The solo purpose is to have an easy to use and easy to read logger class\n\n### Why is it ugly but not that ugly?\n- it is easy to use and easy to read\n- I may keep this library up-to-date and even optimize it in the future\n- at least it has a CI/CD pipeline\n\n## Installation\n\n`pip install uglylogger`\n\n## Release Notes\n\n[Release notes](RELEASE_NOTES.md)  \n\n## Usage\n\n### Instantiate\n```\n# A logger which can log both to console and to a file\nlogger = Logger(\"name\", \"file.log\")  \n\n# A logger which can only log to console\nlogger = Logger(\"name\")  \n```\n\n### Release the resources\n```\nlogger.release()\n```\n- Releases the resources, it's safe to delete the log file after calling this method\n\n### Color Mode\n```\nlogger.set_color_mode(LogColorMode.COLORED)\n```\n- coloroed output if the console/terminal supports it\n```\nlogger.set_color_mode(LogColorMode.MONO)\n```\n- no color used for the console/terminal output\n\n### Log to console\n```\nlogger.console(\"Message\", color=LogColor.BLACK, level=LogLevel.DEBUG)\n```\n- color and level are optional\n- if not provided, default color is BLACK\n- if not provided, default level is DEBUG\n\n### Log to file\n```\nlogger.file(\"Message\", level=LogLevel.DEBUG)\n```\n- level is optional\n- if not provided, default level is DEBUG\n- if instantiated without a file name, nothing happens\n\n### Log to both file and console\n```\nlogger.log(\"Message\", color=LogColor.BLACK, level=LogLevel.DEBUG, output=LogOutput.ALL)\n```\n- color, level and output are optional\n- if not provided, default color is BLACK\n- if not provided, default level is DEBUG\n- if not provided, default output is ALL\n- if instantiated without a file name, writing to file is ignored\n\n\n### Other ways of logging\n\n`logger.debug(\"Message\", color=LogColor.BLACK, output=LogOutput.ALL)`  \n`logger.info(\"Message\", color=LogColor.BLACK, output=LogOutput.ALL)`  \n`logger.warning(\"Message\", color=LogColor.BLACK, output=LogOutput.ALL)`  \n`logger.error(\"Message\", color=LogColor.BLACK, output=LogOutput.ALL)`  \n`logger.critical(\"Message\", color=LogColor.BLACK, output=LogOutput.ALL)`  \n\n### Available LogColor\n    - BLACK\n    - RED\n    - GREEN\n    - YELLOW\n    - BLUE\n    - MAGENTA\n    - CYAN\n    - WHITE\n\n### Available LogLevel\n    - DEBUG\n    - INFO\n    - WARNING\n    - ERROR\n    - CRITICAL\n\n### Available LogOutput\n    - NONE\n    - CONSOLE\n    - FILE\n    - ALL\n\n## set log format\n```\nlogger.set_format([\n    ...\n    LogFormatBlock.XXX\n    ...\n])\n```\n\n### Available LogFormatBlock\n    - NAME\n    - LEVEL\n    - DATETIME\n    - MESSAGE\n    - FILE\n    - LINE\n    - FUNCTION\n\n### Example Formats\n```\nlogger.set_format([LogFormatBlock.MESSAGE])\nlogger.console(\"Hello World!\")\n# Output : Hello World!\n```\n```\nlogger.set_format([\n    \"[\",\n    LogFormatBlock.LEVEL,\n    \"] \",\n    LogFormatBlock.MESSAGE]\n)\nlogger.console(\"Hello World!\")\n# Output : [DEBUG] Hello World!\n```\n\n\n### <a name=\"function_move\"></a> Move the log file to another location\n```\nlogger.move(new_file: str, option: LogMoveOption)\n# Output : Hello World!\n```\n### Available LogMoveOption\n    - MOVE_AND_APPEND  \n       Moves the log file to the destination\n       Deletes if there's already a file in the destination\n       Appends to the moved file\n       Old file is obviously deleted\n    - COPY_AND_APPEND  \n       Copies the log file to the destination\n       Deletes if there's already a file in the destination\n       Appends to the moved file\n       Old file is obviously remains    \n    - KEEP_AND_APPEND  \n       Keeps the old log file\n       Appends if there's already a file in the destination\n       Creates a new file if not\n    - KEEP_AND_INIT  \n       Keeps the old log file\n       Creates a new file in the destination    \n    - DELETE_AND_INIT  \n       Deletes the old log file\n       Creates a new file in the destination\n       \n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 sevketcaba  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "An ugly, slow Logger class for python",
    "version": "0.8.0",
    "project_urls": {
        "Bug Reports": "https://github.com/sevketcaba/uglylogger/issues",
        "Homepage": "https://github.com/sevketcaba/uglylogger",
        "Source": "https://github.com/sevketcaba/uglylogger/"
    },
    "split_keywords": [
        "python",
        " python3",
        " log",
        " logger",
        " oop",
        " pretty",
        " ugly"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "589b75baeaeeefbe9f1ad6ee468af7405a1770a061d8c34a91752618a198ed8f",
                "md5": "f5b7efe0d0b614e78b5aec517357ab3d",
                "sha256": "e0ce905a6f5491db4f34c7050dc19610f665f02e7addc79c943f217e1dccfce2"
            },
            "downloads": -1,
            "filename": "uglylogger-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f5b7efe0d0b614e78b5aec517357ab3d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 10093,
            "upload_time": "2024-03-22T00:14:32",
            "upload_time_iso_8601": "2024-03-22T00:14:32.989399Z",
            "url": "https://files.pythonhosted.org/packages/58/9b/75baeaeeefbe9f1ad6ee468af7405a1770a061d8c34a91752618a198ed8f/uglylogger-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9773f790d23b35dd64aa302e04bbcdb398aeeb12070858ed7e553bc6b4d6ae14",
                "md5": "ac59ac2d689e6b765779052f195d87db",
                "sha256": "e9e6965133436d3943e89aeb23beaeffb8421918752fe98d932f1c8c78d7d387"
            },
            "downloads": -1,
            "filename": "uglylogger-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ac59ac2d689e6b765779052f195d87db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 15155,
            "upload_time": "2024-03-22T00:14:34",
            "upload_time_iso_8601": "2024-03-22T00:14:34.601513Z",
            "url": "https://files.pythonhosted.org/packages/97/73/f790d23b35dd64aa302e04bbcdb398aeeb12070858ed7e553bc6b4d6ae14/uglylogger-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-22 00:14:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sevketcaba",
    "github_project": "uglylogger",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "uglylogger"
}
        
Elapsed time: 0.19907s