-
Notifications
You must be signed in to change notification settings - Fork 37
Rtop 78 create log filters #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
11e9d9a
Add plugin driver system with config parsing
marconetsf fb3b5d0
Refactor plugin driver for Python Modbus support
marconetsf cd10661
sync plugin driver
marconetsf 158b390
Adjusting python.h include
marconetsf 77dbf44
fix init driver's args encapsulation
marconetsf b10e7b8
adjusting brackets position and function identation
marconetsf 75dfe2f
fix cmakelist
marconetsf e89ff10
adjust python_plugin_bridge.h identation
marconetsf ccef749
python start funct running within a thread
marconetsf ce90100
fixing pointer dereferencing
marconetsf 3063116
Fix buffer access in Python plugin driver
marconetsf ef9b1ae
deleting stop call
marconetsf 39a893d
Remove unused _runtime_args_capsule variable
marconetsf df1ac5d
Refactor Python plugin threading and lifecycle management
marconetsf 89e8a3e
Refactor plugin driver cleanup and GIL management
marconetsf 32fc0ec
Refactor plugin loop to run in a separate thread
marconetsf 993cfef
Refactor Modbus plugin for safer buffer access
marconetsf 763b105
Update Python plugin documentation and type safety
marconetsf d447cc1
moving examples and plugins to respective folder
marconetsf 85ac4cb
deleting unused plugins from config
marconetsf 79bb1b6
Expose plugin mutex helpers and use in PLC cycle
marconetsf c3c0ac9
Merge branch 'development' into task/RTOP-57-implement-driver-contracts
marconetsf e5cfc77
Changing pluggins paths to meet exec.sh start path
marconetsf 345fc60
Merge pull request #5 from Autonomy-Logic/task/RTOP-57-implement-driv…
thiagoralves 469fc7b
Rtop 58 plugin modbus slave (#6)
marconetsf 70c560e
Merge branch 'development' into RTOP-52-Standard-Network-Driver
marconetsf 9cf4e5f
fixing plugin's dedicated data retrieval
marconetsf 9bb279c
RTOP 74 adding plugin individual venv usage
marconetsf 2771514
Merge branch 'development' into RTOP-74-Define-venv-environment-for-p…
marconetsf 14301df
Merge branch 'development' into RTOP-52-Standard-Network-Driver
marconetsf 69d1056
Update scripts/manage_plugin_venvs.sh
marconetsf cefb954
Disabling initial plugin prints and avoiding code insertion
marconetsf b021601
Merge branch 'RTOP-74-Define-venv-environment-for-python-plugins' of …
marconetsf f8ab311
install now has support for apt yum and dfs and plc program is being …
marconetsf e086fea
adding proper build error and success logs
marconetsf 55dfcd2
[RTOP 74][WIP] implementing initialization scripts
marconetsf 7f98748
changing runtime venv from .venv to venvs/runtime/
marconetsf 43e43ac
Merge branch 'development' into RTOP-52-Standard-Network-Driver
marconetsf 950a475
Merge branch 'RTOP-52-Standard-Network-Driver' into RTOP-74-Define-ve…
thiagoralves 659f49b
Merge pull request #11 from Autonomy-Logic/RTOP-74-Define-venv-enviro…
thiagoralves a919d86
Add requirements.txt to the Modbus driver
thiagoralves c2acb8c
Add checks on install and start_openplc scripts
f8974ee
Quick fix on start_openplc.sh
aad7e53
Fix zip file check to allow generated bash script
lucasbutzke 865c429
[RTOP-72] Parse and log unix socket log messages
lucasbutzke 8791754
[RTOP-72] Additional Exceptions
lucasbutzke debb9e9
[RTOP-72] Logging format refactor
lucasbutzke 4d65c3d
[RTOP-76] Logging module
lucasbutzke c1f7aa7
Merge branch 'fix-reastapi-zip-file-check' into RTOP-76-Runtime-logs-…
lucasbutzke b0ea1fd
[RTOP-76] Logger parser
lucasbutzke 58b5f48
[RTOP-76] Logger in app
lucasbutzke 7287680
Merge branch 'development' into RTOP-76-Runtime-logs-parser
lucasbutzke 7dd4fc3
[RTOP-76] Runtime logging buffer test
lucasbutzke 6651c8c
[RTOP-76] Fix logging instantiation, parser and buffer
lucasbutzke b8bff1e
[RTOP-76] Runtime Logs parser, buffering and json response
lucasbutzke 145dade
Merge branch 'development' into RTOP-78-Create-log-filters
lucasbutzke 0f07f85
[RTOP-77] Python logs parsing to JSON
lucasbutzke 74ef50e
[RTOP-78] Fix python restapi logging format
lucasbutzke 7acdcdd
[RTOP-78] Logs id field
lucasbutzke 4dd1e49
Merge remote-tracking branch 'origin/development' into RTOP-76-Runtim…
lucasbutzke 7d9915b
Merge branch 'RTOP-76-Runtime-logs-parser' into RTOP-78-Create-log-fi…
lucasbutzke 0b8319a
[RTOP-78] Adding python logging messages
lucasbutzke b7c08b3
[RTOP-78] Logs simple filter
lucasbutzke 64c0582
[RTOP-78] Fix logs filter
lucasbutzke 7a74e9b
Update webserver/plcapp_management.py
lucasbutzke f7e7791
[RTOP-78] db exceptions COPILOT fix sugestions
lucasbutzke 2c3d6c2
[RTOP-78] Fix kwt Exception COPILOT sugestion
lucasbutzke f5ec8d6
Merge branch 'development' into RTOP-78-Create-log-filters
lucasbutzke 0fd3cfb
[RTOP-78] Remove allowed bash file in zip
lucasbutzke 117636d
[RTOP-78] Remove json library that is not used in this file
lucasbutzke 894e604
[RTOP-78] Fix and removing Exceptions imports
lucasbutzke f0c3d7e
Fix failed build due to logger
thiagoralves e302448
[RTOP-78] Fix restapi database and env directory location for docker …
lucasbutzke e806a0d
[RTOP-78] config.py import logging module
lucasbutzke 2170d37
Update webserver/runtimemanager.py
lucasbutzke 8c45b4f
Update webserver/logger/bufferhandler.py
lucasbutzke d2bc4f5
[RTOP-78] Removing commented code
lucasbutzke 2aebd4c
Merge branch 'RTOP-78-Create-log-filters' into development
lucasbutzke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ __pycache__/ | |
| *.pem | ||
| *.db | ||
| *.socket | ||
| *.installed | ||
|
|
||
| # Ignore all object files and shared libraries | ||
| *.o | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,33 +1,29 @@ | ||
| import logging | ||
| import logging.config | ||
| from .logger import get_logger | ||
| from .parser import LogParser | ||
| from .bufferhandler import BufferHandler | ||
| from .formatter import JsonFormatter | ||
|
|
||
| __all__ = ["get_logger", "LogParser", "BufferHandler"] | ||
| __all__ = ["get_logger", "LogParser", "BufferHandler", "JsonFormatter"] | ||
| __version__ = "0.1" | ||
| __author__ = "Autonomy" | ||
| __license__ = "MIT" | ||
| __description__ = "RestAPI interface for runtime core" | ||
|
|
||
| # Single global buffer for all logs | ||
| shared_buffer_handler = BufferHandler() | ||
|
|
||
| # Configure logging once | ||
| logging.config.dictConfig( | ||
| { | ||
| "version": 1, | ||
| "formatters": { | ||
| "default": { | ||
| "format": "[%(levelname)s] %(asctime)s - %(name)s - %(message)s", | ||
| "datefmt": "%H:%M:%S", | ||
| } | ||
| }, | ||
| "handlers": { | ||
| "console": { | ||
| "class": "logging.StreamHandler", | ||
| "formatter": "default", | ||
| "level": "DEBUG", | ||
| } | ||
| }, | ||
| "root": {"level": "DEBUG", "handlers": ["console"]}, | ||
| } | ||
| ) | ||
| formatter = JsonFormatter() | ||
| shared_buffer_handler.setFormatter(formatter) | ||
|
|
||
| def get_logger(name="runtime", use_buffer: bool = False): | ||
| """Return a logger that shares the same buffer handler.""" | ||
| logger = logging.getLogger(name) | ||
| logger.setLevel(logging.DEBUG) | ||
| logger.propagate = False | ||
|
|
||
| if use_buffer: | ||
| if not any(isinstance(h, BufferHandler) for h in logger.handlers): | ||
| logger.addHandler(shared_buffer_handler) | ||
|
|
||
| return logger, shared_buffer_handler | ||
This file contains hidden or 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 hidden or 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,19 +1,35 @@ | ||
| from datetime import datetime, timezone | ||
| import logging | ||
| import time | ||
| import json | ||
|
|
||
|
|
||
| class JsonFormatter(logging.Formatter): | ||
| """Format log records as JSON strings.""" | ||
| log_id = 0 | ||
|
|
||
| def format(self, record): | ||
| msg = record.getMessage() | ||
| self.log_id += 1 | ||
|
|
||
| def format(self, record: logging.LogRecord) -> str: | ||
| log_dict = { | ||
| "timestamp": str(int(record.created)), # epoch seconds | ||
| # Try to detect pre-formatted JSON | ||
| if msg.strip().startswith("{") and msg.strip().endswith("}"): | ||
| try: | ||
| parsed = json.loads(msg) | ||
| # Already JSON — just make sure timestamp exists | ||
| if "timestamp" not in parsed: | ||
| parsed["timestamp"] = datetime.now(timezone.utc).isoformat() | ||
| parsed["id"] = self.log_id | ||
| return json.dumps(parsed) | ||
|
|
||
| except json.JSONDecodeError: | ||
| pass # continue to default formatting | ||
|
|
||
| # Not JSON, so create our standard JSON structure | ||
| log_entry = { | ||
| "id": self.log_id, | ||
| "timestamp": datetime.now(timezone.utc).isoformat(), | ||
| "level": record.levelname, | ||
| "message": record.getMessage() | ||
| "message": msg, | ||
| } | ||
| return json.dumps(log_entry) | ||
|
|
||
| # Include optional fields if present | ||
| if hasattr(record, "source"): | ||
| log_dict["source"] = record.source | ||
|
|
||
| return json.dumps(log_dict, ensure_ascii=False) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.