Add service ID to log entry instead of module name (#588)

This commit is contained in:
cybermaggedon 2025-12-10 11:07:43 +00:00 committed by GitHub
parent aebdf9444b
commit 727b6bc9d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -133,10 +133,14 @@ def setup_logging(args):
print(f"WARNING: Failed to setup Loki logging: {e}")
print("Continuing with console-only logging")
# Get processor ID for log formatting (use 'unknown' if not available)
processor_id = args.get('id', 'unknown')
# Configure logging with all handlers
# Use processor ID as the primary identifier in logs
logging.basicConfig(
level=getattr(logging, log_level.upper()),
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
format=f'%(asctime)s - {processor_id} - %(levelname)s - %(message)s',
handlers=handlers,
force=True # Force reconfiguration if already configured
)

View file

@ -168,6 +168,12 @@ def run():
description=__doc__
)
parser.add_argument(
'--id',
default='api-gateway',
help='Service identifier for logging and metrics (default: api-gateway)',
)
parser.add_argument(
'-p', '--pulsar-host',
default=default_pulsar_host,