-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5623 from wazuh/change/5614-change-allocator-logs…
…-to-reference-tasks-instead-of-generic-values Add task information in the allocation logs when create or delete an instance
- Loading branch information
Showing
6 changed files
with
37 additions
and
5 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
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
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 |
---|---|---|
|
@@ -2,6 +2,27 @@ | |
# Created by Wazuh, Inc. <[email protected]>. | ||
# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 | ||
|
||
import logging | ||
from modules.allocation.generic.instance import Instance | ||
from modules.allocation.generic.models import TrackOutput | ||
from modules.generic.logger import Logger | ||
|
||
# Default logger | ||
logger = Logger("allocator").get_logger() | ||
|
||
|
||
def logger_with_instance_name(instance_info: Instance | TrackOutput) -> logging.Logger: | ||
""" | ||
Returns a logger with the instance name if it is different from the identifier, | ||
otherwise returns the default logger without the name. | ||
Args: | ||
instance (Instance): The instance object. | ||
Returns: | ||
logging.Logger: The logger object. | ||
""" | ||
|
||
if instance_info.name != instance_info.identifier: | ||
return Logger(f"allocator [{instance_info.name}]").get_logger() | ||
return logger |
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