ScrapMods/Logger/README.md

41 lines
558 B
Markdown
Raw Normal View History

2023-02-06 17:46:47 +00:00
# Logger
2023-02-07 08:38:24 +00:00
Logger for logging stuff. Thanks to @earthnuker.
2023-02-06 17:46:47 +00:00
2023-02-07 08:38:24 +00:00
Quick snippet for initialisation in your `.py` file
2023-02-06 17:46:47 +00:00
2023-02-07 08:38:24 +00:00
```python
logger = None
try:
logger = __import__("Logger").Logger("Police")
except Exception:
pass
def log(msg):
if logger is not None:
logger.info(msg)
else:
Scrap.Print("[Logger][File] " + str(msg) + "\n")
log("Starting module")
logger.info("A")
logger.error("OH NO!")
2023-02-06 17:46:47 +00:00
```
2023-02-07 08:38:24 +00:00
NOTE: Never do something like:
```python
if logger:
this
else:
that
```
It will crahs.
TODO: come up with better system