{"id":23288246,"url":"https://github.com/gruvw/printbetter","last_synced_at":"2025-04-06T16:29:51.841Z","repository":{"id":57454830,"uuid":"254402561","full_name":"gruvw/printbetter","owner":"gruvw","description":"Python Module for better printing and logging","archived":false,"fork":false,"pushed_at":"2021-08-25T20:49:42.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T05:41:49.967Z","etag":null,"topics":["debug","logging","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gruvw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-09T15:01:42.000Z","updated_at":"2022-01-08T08:09:02.000Z","dependencies_parsed_at":"2022-09-05T05:11:22.846Z","dependency_job_id":null,"html_url":"https://github.com/gruvw/printbetter","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruvw%2Fprintbetter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruvw%2Fprintbetter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruvw%2Fprintbetter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruvw%2Fprintbetter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gruvw","download_url":"https://codeload.github.com/gruvw/printbetter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247512080,"owners_count":20950783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debug","logging","python"],"created_at":"2024-12-20T03:15:44.098Z","updated_at":"2025-04-06T16:29:51.816Z","avatar_url":"https://github.com/gruvw.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PrintBetter\r\n\r\n---\r\n\r\n## Description\r\n\r\nI created this module because I had had enough of writing and rewriting the same piece of code every time I needed to print something in Python 💢.\r\nI wanted two things:\r\n\r\n- To be able to keep what I had printed on the console after I having closed it -\u003e log file 📁\r\n- To see the time when the print was executed -\u003e print prefix ⌚️\r\n\r\nIn addition to all that I added a simple and nice feature which is multiple print \"types\":\r\n\r\n- Information [INFO] -\u003e the basic one, replaces the old `print`\r\n- Debugging [DEBUG] -\u003e when you print something just to see a variable content, Oh yeah you need this!\r\n- Warning [WARNING] -\u003e when you need to show a warning\r\n- Error [ERROR] -\u003e when you need to display that an error occurred, so we do not need to use `raise` which prints a massive and ugly block of red code inside your clean and sweet console\r\n\r\nIt also had to be fully customizable because I hate it when I am forced to use some part of a module that I do not really like 💯.\r\n\r\nFeel free to make a pull request if you have any upgrade idea.\r\n\r\nThat is it! A new way to print things in python! ✅\r\n\r\n## Features\r\n\r\nUse PrintBetter to have a nice prefix before printing anything on the console output.\r\nIt also creates a clean log file where you can find anything that you have printed during the program execution. 😊\r\n\r\n## ⚡️ Quick Start\r\nInstallation is really simple:\r\n\r\n```bash\r\npip install printbetter\r\n```\r\n\r\n## Usage\r\n\r\nYou need to initialize the module in order to have the log file set up properly:\r\n\r\n```python\r\nimport printbetter as pb\r\n\r\npb.init()  # Initializes the log file and the printing format\r\n\r\npb.info(\"Everything is set up properly!\")\r\n```\r\n\r\n## ✏️ Default example\r\n\r\n```python\r\nimport printbetter as pb\r\n\r\npb.init()\r\n\r\npb.info(\"information\")\r\npb.debug(\"variable debug\")\r\npb.warn(\"warning\")\r\npb.err(\"error\")\r\n```\r\n\r\n## Imports\r\n\r\nThis module uses 2 other modules that it imports:\r\n\r\n- time\r\n- os\r\n\r\n(no need to install anything, the 2 modules are in the Standard Python Module Library)\r\n\r\n## Documentation\r\n\r\nThe full documentation 📄 below comes directly from the code's docstring. It makes the documentation readable directly from any compatible IDE or text editors. I recommend using [Visual Studio Code](https://code.visualstudio.com/).\r\n\r\n### Initialization `init()`\r\n\r\nYou should call this function before logging anything in your program.\r\nInitializes the module: creates the log file in the right path and defines the logging format.\r\nIf needed all the different parameters are here to set each variable without using the proper function.\r\n\r\n#### Definition\r\n\r\n```python\r\ndef init(print_out=True, log_file=True, log_path=\"logs/logfile_%d-%m-%y_%H.%M.%S.log\",\r\n         log_format='[%(asctime)s] %(levelname)s : %(message)s', log_date_fmt='%d/%m/%y %H:%M:%S',\r\n         print_prefix_format=\"[%d/%m/%y %H:%M:%S]\"):\r\n```\r\n\r\n### Information `info(text)`\r\n\r\nLogs an information out.\r\n\r\n#### Log result\r\n\r\n```log\r\n[09/04/20 11:14:40] INFO : information\r\n```\r\n\r\n### Debug `debug(debug_info)`\r\n\r\nLogs a debugging information out.\r\n\r\n#### Log result\r\n\r\n```log\r\n[09/04/20 11:14:40] DEBUG : variable debug\r\n```\r\n\r\n### Warning `warn(warning)`\r\n\r\nLogs a warning out.\r\n\r\n#### Log result\r\n\r\n```log\r\n[09/04/20 11:14:40] WARNING : warning\r\n```\r\n\r\n### Error `err(error)`\r\n\r\nLogs an error out.\r\n\r\n#### Log result\r\n\r\n```log\r\n[09/04/20 11:14:40] ERROR : error\r\n```\r\n\r\n### Disable the log file feature `disable_LOG_FILE()`\r\n\r\nDisables the creation of the log file and the logging into an existing log file for the next printbetter functions.\r\n\r\n#### Example\r\n\r\n```python\r\npb.disable_LOG_FILE()  # Disables the log file\r\npb.init()  # Initializes the printing format\r\npb.info(\"Everything is set up properly!\")  # Formats the text and prints it on the console only\r\n```\r\n\r\n### Enable the log file feature `enable_LOG_FILE()`\r\n\r\nRe-enables the creation of the log file and the logging into the log file for next printbetter functions.\r\n\r\n#### Example\r\n\r\n```python\r\npb.init()  # Initializes the printing format\r\npb.info(\"Everything is set up properly!\")  # Printed on the console and written in the log file\r\npb.disable_LOG_FILE()  # Disables the log file\r\npb.info(\"Just print this!\")  # Only printed on the console\r\npb.enable_LOG_FILE()  # Enables the logging into the log file\r\npb.info(\"Everything is set up properly!\")  # Printed on the console and written in the log file\r\n```\r\n\r\n### Disable the print feature `disable_PRINT_OUT()`\r\n\r\nDisables the printing on the console for next printbetter functions.\r\n\r\n#### Example\r\n\r\n```python\r\npb.disable_PRINT_OUT()  # Disables the console printing\r\npb.init()  # Initialization\r\npb.info(\"Everything is set up properly!\")  # Formats the text and writes it in the log file only\r\n```\r\n\r\n### Enable the print feature `enable_PRINT_OUT()`\r\n\r\nRe-enables the console printing for next printbetter functions.\r\n\r\n#### Example\r\n\r\n```python\r\npb.init()  # Initialization\r\npb.info(\"Everything is set up properly!\")  # Printed on the console and written in the log file\r\npb.disable_PRINT_OUT()  # Disables the console printing\r\npb.info(\"Just log this!\")  # Only written in the log file\r\npb.enable_PRINT_OUT()  # Enables the console printing\r\npb.info(\"Everything is set up properly!\")  # Printed on the console and written in the log file\r\n```\r\n\r\nThis module was developed by Lucas Jung alias [@Gruvw](https://github.com/gruvw).\r\nContact me directly on GitHub or via E-Mail at: gruvw.dev@gmail.com\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruvw%2Fprintbetter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgruvw%2Fprintbetter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruvw%2Fprintbetter/lists"}