Skip to content

Simplify logging infrastructure and refactor audit handling#1010

Open
cgalibern wants to merge 10 commits intoopensvc:mainfrom
cgalibern:dev
Open

Simplify logging infrastructure and refactor audit handling#1010
cgalibern wants to merge 10 commits intoopensvc:mainfrom
cgalibern:dev

Conversation

@cgalibern
Copy link
Copy Markdown
Contributor

Description

This pull request simplifies and improves the logging infrastructure across various components by addressing several inefficiencies, unused methods, and redundant logic. It also resolves multiple issues related to audit handling and listener management.

Key Changes:

  • Logger Refactor:

    • Removed unused WithQ method from the Logger class.
    • Streamlined logger cloning, queue handling, and prefix management via a centralized head logger.
    • Replaced LogQueue with simplified direct context-based logger setup.
  • Audit Handling Improvements:

    • Fixed goroutine leaks and listener restarts during audit requests.
    • Updated audit subsystem filtering logic for better maintainability and targeted API support.
    • Adjusted timing of attachActiveAuditIfAny for improved worker initialization.
  • Middleware and Listener Changes:

    • Simplified logger injection into middleware and API contexts using WithLogger.
    • Refactored listener logging mechanisms to preserve log prefixes and attributes dynamically.
    • Corrected log messages for listener restart checks to ensure accuracy.

Type of Change

  • Bug fix
  • Refactor
  • Improvement

…nitialization

- Attach active audit early in `worker` lifecycle for improved initialization.
- Increase log level from `Tracef` to `Debugf` for config update messages.
- Add log message upon new configuration publication for better traceability.
- Introduce `head` to manage logger chain and ensure proper cloning behavior.
- Adjust queue (`q`) handling logic for consistency across logger instances.
- Simplify and streamline attribute addition with centralized cloning logic.

This commit enables the master queue manager (ie the head logger) q value is
 cloned on children (Attr/Prefix...).

It will be used on the lsnrhttpinet & lsnrhttpux.
This commit fixes following issues:
- restarts listener on audit requests: leads to unavailable ux socket during audit AuditStart/AuditStop
- janitor.start func routine hang on: err := <-errC
	start := func() error {
		t.log.Infof("janitor ask for start")
		errC := make(chan error)
		go t.Start(ctx)
		err := <-errC
- Unexpected log attribute "pkg": "daemon/listener/lsnrhttpinet".
- Unexpected log prefix: "daemon: listener: inet:".

Implementation:
- Simplify janitor by removing unused `start` and `restart` logic.
- Introduce logger injection in `lsnrhttpux` initialization using `WithLogger`.
  So the api middleware will inherit the head logger and its queue setting
- Replace `LogQueue` with `Logger` for streamlined logger context management.
- Refactor `WithLogQueue` and `LogQueue` to `WithLogger` and `Logger`.
- Remove unused `slices` import and redundant janitor restart logic.
- Adjust audit subsystem handling for improved API-based filtering.
…ddr reassignments

    will restart: addr changed :0 -> :0
    instead of
    will restart: addr changed :0 -> :1215
This commit simplifies logger injection and streamline audit handling

- Remove redundant `slices` import and unused restart logic.
- Inject logger directly into context using `WithLogger`.
- Refactor audit subsystem handling for targeted API filtering (`api`, `api.inet`, `api.ux`).
- Eliminate outdated queue (`LogQueue`) management in favor of streamlined logger context.
- Refactor `logWithFamilyAndAddr` to derive logger attributes directly from context.
- Remove redundant `LogQueue` management in favor of direct context-based logger setup.
- Consolidate logger initialization to streamline middleware logic.
- Preserve log prefixes across request contexts.
Simplify logger setup and refactor log handling

- Replace individual logger creation with `logSetOrchestrationID` for consistency.
- Consolidate logger prefix management to ensure dynamic updates during state changes.
- Remove redundant logger initialization methods (`newLogger`, `newResourceLogger`).
- Add timeouts to ensure preempt channel operations do not block indefinitely.
- Verify if preempt is still needed when session might be closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant