https://github.com/houshmand-2005/py2hlog
Python logs to HTML formatter
https://github.com/houshmand-2005/py2hlog
html logger logger-python python
Last synced: 3 months ago
JSON representation
Python logs to HTML formatter
- Host: GitHub
- URL: https://github.com/houshmand-2005/py2hlog
- Owner: houshmand-2005
- License: mit
- Created: 2022-09-17T17:36:16.000Z (almost 3 years ago)
- Default Branch: houshmand
- Last Pushed: 2023-02-17T18:54:23.000Z (over 2 years ago)
- Last Synced: 2025-02-14T19:08:10.774Z (4 months ago)
- Topics: html, logger, logger-python, python
- Language: Python
- Homepage: https://pypi.org/project/py2hlog/
- Size: 506 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# py2hlog (Python to HTML log)
see it from pypi [pypi.org/project/py2hlog/](https://pypi.org/project/py2hlog/)Python logs to HTML formatter
install py2hlog:
```bash
pip install py2hlog
```simple useage :
```bash
from py2hlog import logger
import time
obj1 = logger.py2hlog() # create an object from py2hlog
obj1.file_name = "new_log_file.txt" # here write the log detail
try:
if a == 2:
print("Iam working!")
except:
obj1.error("I dont have any 'a' variable")
print("print obj1: ", obj1)
time.sleep(5) # to see time changing
obj1.debug("Add a variable before the 'if' like a = 3")
obj1.makehtml("py2hlog.html") # enter the name of output file
# you can also use these statuses :
# _____________________________
# obj1.critical("your message")
# obj1.debug("your message")
# obj1.info("your message")
# obj1.warning("your message")
# obj1.error("your message")
# _____________________________```
**py2hlog.html** output :
All of the statuses:
You can also see which file the log belongs to and when the log was added. like this:
Also you can mark a part of your code for each status like this:
```bash
from py2hlog import logger
object_of_py2hlog = logger.py2hlog()
object_of_py2hlog.file_name = "Py2hlog.txt"
object_of_py2hlog.warning("you can also mark a part of code for this status like -->", 1, 5)
# ("msg", start line, end line)
object_of_py2hlog.makehtml("Py2hlog.html")
```output :
As you can see, when you click on 'see code', the codes will appear
what is new :
✨ Add the ability to show the contents of the executable file folder and display it![]()
✨After the last update(V1.2) we have a better style for tree:
Before After
![]()
![]()
If you want to disable the tree display (Important note "You must define it before the logs statement like the following code")
```bash
from py2hlog import logger
object_of_py2hlog = logger.py2hlog()
logger.Add_Tree = False
object_of_py2hlog.file_name = "Py2hlog.txt"
object_of_py2hlog.warning("", 1, 5)
object_of_py2hlog.makehtml("Py2hlog.html")
```
houshmand2005