Add bpf_logging/src/bpf_logging/cli.py
This commit is contained in:
parent
d8507ca74b
commit
7f074a7ae6
1 changed files with 46 additions and 0 deletions
46
bpf_logging/src/bpf_logging/cli.py
Normal file
46
bpf_logging/src/bpf_logging/cli.py
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
from bpf_logging import core
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""CLI entry point for BPF Logging module."""
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="BPF Logging CLI for Timekeeping Analysis"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--correlation-id",
|
||||||
|
required=True,
|
||||||
|
help="Eindeutige ID zur Korrelation von Logging-Daten."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--event-type",
|
||||||
|
required=True,
|
||||||
|
help="Art des zu loggenden Ereignisses, z. B. 'first_tkread'."
|
||||||
|
)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Input validation
|
||||||
|
correlation_id = args.correlation_id.strip()
|
||||||
|
event_type = args.event_type.strip()
|
||||||
|
|
||||||
|
if not correlation_id:
|
||||||
|
print("Fehler: Leere correlation-id.", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not event_type:
|
||||||
|
print("Fehler: Leerer event-type.", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
core.setup_bpf_logging(correlation_id)
|
||||||
|
core.log_timekeeping_event(event_type, correlation_id)
|
||||||
|
print(f"Event '{event_type}' mit correlation-id '{correlation_id}' geloggt.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Fehler beim Ausführen des BPF Logging: {e}", file=sys.stderr)
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in a new issue