Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anuja-rahul/python_datalogger
simplified datalogger using python for easier and faster data logging.
https://github.com/anuja-rahul/python_datalogger
easy-to-use logging-library python-package
Last synced: about 7 hours ago
JSON representation
simplified datalogger using python for easier and faster data logging.
- Host: GitHub
- URL: https://github.com/anuja-rahul/python_datalogger
- Owner: anuja-rahul
- License: mit
- Created: 2024-01-17T07:58:06.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-02-09T07:33:36.000Z (9 months ago)
- Last Synced: 2024-02-14T11:34:41.960Z (9 months ago)
- Topics: easy-to-use, logging-library, python-package
- Language: Python
- Homepage: https://test.pypi.org/project/python-datalogger/
- Size: 86.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## python_datalogger (v0.0.4)
#### Simplified datalogger using python for easier and faster data logging.Datalogger will save all the recorded logs in a local directory (./logs)
## How to install datalogger from test-pypi
#### Visit :
[https://test.pypi.org/project/python-datalogger/](https://test.pypi.org/project/python-datalogger/)
#### Or run on your terminal :
pip install -i https://test.pypi.org/simple/ python-datalogger## How to install datalogger locally
01. Download this project.
02. Extract the master zip file
03. Open command prompt in the master folder location
04. Run (for windows) -> pip install .
Run (for mac) -> pip3 install .Now you can use datalogger locally any time you want
### How to use Datalogger.logger decorator for basic exception handling. (Example):
```pythonfrom python_datalogger import DataLogger
# using datalogger decorator to record basic exceptions
@DataLogger.logger
def test_method(num: int) -> float:
return 1000/numtest_method(2) # if no exceptions are encountered, logs the time taken for this method to run
# raises ZeroDivisionError for demonstration
test_method(0) # logs the error, in case of an exception```
### How to use Datalogger.timeit decorator to time a function runtime. (Example):
```python
from python_datalogger import DataLogger@DataLogger.timeit
def test_method(num: int) -> float:
return 1000/numtest_method(10) # displays the runtime before returning the result for test_method
```### How to use datalogger for specific info logging. (Example):
```pythonfrom python_datalogger import DataLogger
logger = DataLogger(name="TestLogger", level="DEBUG", propagate=True)
# name can be any name you like for the current instance of the Datalogger
# level has 5 security options (DEBUG, INFO, WARNING, ERROR, CRITICAL)
# propagate has 2 options (True/False), if true, the current log is displayed on the terminaldef test_method():
try:
print("Starting to do something !")# logs a regular information log
logger.log_info("test_method did something !")except Exception as exception:
# in case of an exception, logs an error log containing the specified exception
logger.log_error(str(exception))test_method()
```
### There are 5 possible types of logging methods you can use for each security level.
```python
from python_datalogger import DataLoggerlogger = DataLogger(name="TestLogger", level="DEBUG", propagate=True)
logger.log_debug(info="this is a debug log")
logger.log_info(info="this is an info log")
logger.log_warning(info="this is a warning log")
logger.log_error(info="this is an error log")
logger.log_critical(info="this is a critical log")"""Each of these methods accept one (string) parameter containing the information you want to log."""
```