-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Needs testing with Postman.
- Loading branch information
Showing
11 changed files
with
213 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,40 @@ | ||
import sys | ||
from datetime import datetime | ||
import logging | ||
|
||
LOG_FILE = "monitor-agent.log" | ||
MODE = "a+" | ||
|
||
def getLogger(CONFIG): | ||
log_level = "" | ||
tranlation = { | ||
"debug": logging.DEBUG, | ||
"info": logging.INFO, | ||
"warning": logging.WARNING, | ||
"error": logging.ERROR, | ||
"critical": logging.CRITICAL, | ||
} | ||
try: | ||
if CONFIG.logging.level in tranlation.keys(): | ||
log_level = tranlation[CONFIG.logging.level] | ||
else: | ||
logging.warning("Level not established in Settings.json") | ||
log_level = logging.info | ||
except AttributeError as e: | ||
logging.warning( | ||
"Level not established in Settings.json.\nDefault Info level will be used.", | ||
exc_info=True, | ||
) | ||
log_level = logging.info | ||
|
||
def save2log(filename: str = LOG_FILE, mode: str = MODE, data="", type=""): | ||
log_filename = "" | ||
try: | ||
with open(filename, mode) as f: | ||
timestamp = datetime.now().strftime("%d/%m/%Y:%H:%M:%S") | ||
f.write(f"{type} - - [{timestamp}] : {data}\n") | ||
except OSError as msg: | ||
print(f"ERROR: Couldn't open file {filename} - {msg}", file=sys.stderr) | ||
log_filename = CONFIG.logging.filename | ||
except AttributeError as e: | ||
logging.warning( | ||
'Log filename not established in Settings.json.\nDefault "monitor.log" file will be used.', | ||
exc_info=True, | ||
) | ||
log_filename = "monitor.log" | ||
|
||
return logging.basicConfig( | ||
level=log_level, | ||
filename=log_filename, | ||
format="%(asctime)s - %(levelname)s - %(message)s", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
2022-03-26 15:10:14,033 - INFO - Will watch for changes in these directories: ['/home/pablo/devel/monitor_agent/monitor_agent'] | ||
2022-03-26 15:10:14,033 - INFO - Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) | ||
2022-03-26 15:10:14,033 - INFO - Started reloader process [35964] using statreload | ||
2022-03-26 15:10:14,306 - INFO - Started server process [35969] | ||
2022-03-26 15:10:14,306 - INFO - Waiting for application startup. | ||
2022-03-26 15:10:14,306 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:10:14,306 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:10:14,306 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:10:14,307 - INFO - Application startup complete. | ||
2022-03-26 15:10:28,957 - WARNING - StatReload detected file change in 'core/helper.py'. Reloading... | ||
2022-03-26 15:10:28,991 - INFO - Shutting down | ||
2022-03-26 15:10:29,092 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:10:29,092 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:10:29,093 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:10:29,093 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:10:29,094 - INFO - Application shutdown complete. | ||
2022-03-26 15:10:29,094 - INFO - Finished server process [35969] | ||
2022-03-26 15:10:29,492 - INFO - Started server process [35993] | ||
2022-03-26 15:10:29,493 - INFO - Waiting for application startup. | ||
2022-03-26 15:10:29,493 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:10:29,493 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:10:29,493 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:10:29,493 - INFO - Application startup complete. | ||
2022-03-26 15:10:33,738 - WARNING - StatReload detected file change in 'core/helper.py'. Reloading... | ||
2022-03-26 15:10:33,815 - INFO - Shutting down | ||
2022-03-26 15:10:33,917 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:10:33,918 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:10:33,918 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:10:33,919 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:10:33,919 - INFO - Application shutdown complete. | ||
2022-03-26 15:10:33,919 - INFO - Finished server process [35993] | ||
2022-03-26 15:10:34,262 - INFO - Started server process [36005] | ||
2022-03-26 15:10:34,262 - INFO - Waiting for application startup. | ||
2022-03-26 15:10:34,262 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:10:34,262 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:10:34,263 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:10:34,263 - INFO - Application startup complete. | ||
2022-03-26 15:10:37,679 - INFO - Shutting down | ||
2022-03-26 15:10:37,780 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:10:37,781 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:10:37,781 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:10:37,782 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:10:37,782 - INFO - Application shutdown complete. | ||
2022-03-26 15:10:37,783 - INFO - Finished server process [36005] | ||
2022-03-26 15:10:37,879 - INFO - Stopping reloader process [35964] | ||
2022-03-26 15:10:40,672 - INFO - Will watch for changes in these directories: ['/home/pablo/devel/monitor_agent/monitor_agent'] | ||
2022-03-26 15:10:40,673 - INFO - Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) | ||
2022-03-26 15:10:40,673 - INFO - Started reloader process [36045] using statreload | ||
2022-03-26 15:10:40,944 - INFO - Started server process [36050] | ||
2022-03-26 15:10:40,944 - INFO - Waiting for application startup. | ||
2022-03-26 15:10:40,945 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:10:40,945 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:10:40,945 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:10:40,945 - INFO - Application startup complete. | ||
2022-03-26 15:10:51,286 - WARNING - StatReload detected file change in 'main.py'. Reloading... | ||
2022-03-26 15:10:51,299 - INFO - Shutting down | ||
2022-03-26 15:10:51,400 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:10:51,401 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:10:51,401 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:10:51,402 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:10:51,402 - INFO - Application shutdown complete. | ||
2022-03-26 15:10:51,402 - INFO - Finished server process [36050] | ||
2022-03-26 15:10:51,798 - INFO - Started server process [36066] | ||
2022-03-26 15:10:51,798 - INFO - Waiting for application startup. | ||
2022-03-26 15:10:51,798 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:10:51,799 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:10:51,799 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:10:51,799 - INFO - Application startup complete. | ||
2022-03-26 15:11:46,805 - WARNING - StatReload detected file change in 'main.py'. Reloading... | ||
2022-03-26 15:11:46,839 - INFO - Shutting down | ||
2022-03-26 15:11:46,941 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:11:46,941 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:11:46,942 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:11:46,942 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:11:46,943 - INFO - Application shutdown complete. | ||
2022-03-26 15:11:46,943 - INFO - Finished server process [36066] | ||
2022-03-26 15:11:47,302 - INFO - Started server process [36085] | ||
2022-03-26 15:11:47,302 - INFO - Waiting for application startup. | ||
2022-03-26 15:11:47,302 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:11:47,303 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:11:47,303 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:11:47,303 - INFO - Application startup complete. | ||
2022-03-26 15:12:05,661 - INFO - Shutting down | ||
2022-03-26 15:12:05,762 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:12:05,762 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:12:05,762 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:12:05,762 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:12:05,763 - INFO - Application shutdown complete. | ||
2022-03-26 15:12:05,763 - INFO - Finished server process [36085] | ||
2022-03-26 15:12:05,813 - INFO - Stopping reloader process [36045] | ||
2022-03-26 15:12:38,060 - INFO - Will watch for changes in these directories: ['/home/pablo/devel/monitor_agent/monitor_agent'] | ||
2022-03-26 15:12:38,061 - INFO - Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) | ||
2022-03-26 15:12:38,061 - INFO - Started reloader process [36505] using statreload | ||
2022-03-26 15:12:38,332 - INFO - Started server process [36510] | ||
2022-03-26 15:12:38,333 - INFO - Waiting for application startup. | ||
2022-03-26 15:12:38,333 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:12:38,333 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:12:38,333 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:12:38,333 - INFO - Application startup complete. | ||
2022-03-26 15:12:39,642 - INFO - Shutting down | ||
2022-03-26 15:12:39,743 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:12:39,744 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:12:39,744 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:12:39,745 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:12:39,745 - INFO - Application shutdown complete. | ||
2022-03-26 15:12:39,746 - INFO - Finished server process [36510] | ||
2022-03-26 15:12:39,815 - INFO - Stopping reloader process [36505] | ||
2022-03-26 15:12:44,043 - INFO - Will watch for changes in these directories: ['/home/pablo/devel/monitor_agent/monitor_agent'] | ||
2022-03-26 15:12:44,044 - INFO - Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) | ||
2022-03-26 15:12:44,044 - INFO - Started reloader process [36527] using statreload | ||
2022-03-26 15:12:44,314 - INFO - Started server process [36532] | ||
2022-03-26 15:12:44,315 - INFO - Waiting for application startup. | ||
2022-03-26 15:12:44,315 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:12:44,315 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:12:44,315 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:12:44,315 - INFO - Application startup complete. | ||
2022-03-26 15:12:45,816 - WARNING - StatReload detected file change in 'main.py'. Reloading... | ||
2022-03-26 15:12:45,824 - INFO - Shutting down | ||
2022-03-26 15:12:45,925 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:12:45,925 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:12:45,926 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:12:45,926 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:12:45,926 - INFO - Application shutdown complete. | ||
2022-03-26 15:12:45,927 - INFO - Finished server process [36532] | ||
2022-03-26 15:12:46,320 - INFO - Started server process [36543] | ||
2022-03-26 15:12:46,320 - INFO - Waiting for application startup. | ||
2022-03-26 15:12:46,321 - TRACE - ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}} | ||
2022-03-26 15:12:46,321 - TRACE - ASGI [1] Receive {'type': 'lifespan.startup'} | ||
2022-03-26 15:12:46,321 - TRACE - ASGI [1] Send {'type': 'lifespan.startup.complete'} | ||
2022-03-26 15:12:46,321 - INFO - Application startup complete. | ||
2022-03-26 15:12:47,830 - INFO - Shutting down | ||
2022-03-26 15:12:47,931 - INFO - Waiting for application shutdown. | ||
2022-03-26 15:12:47,932 - TRACE - ASGI [1] Receive {'type': 'lifespan.shutdown'} | ||
2022-03-26 15:12:47,932 - TRACE - ASGI [1] Send {'type': 'lifespan.shutdown.complete'} | ||
2022-03-26 15:12:47,933 - TRACE - ASGI [1] Completed | ||
2022-03-26 15:12:47,933 - INFO - Application shutdown complete. | ||
2022-03-26 15:12:47,933 - INFO - Finished server process [36543] | ||
2022-03-26 15:12:47,982 - INFO - Stopping reloader process [36527] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
d451ddc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
monitor.log
to.gitignore
and see if it comes from the Uvicorn logger or from the logger implemented in this commit.Ref #26 and #27.