Skip to content

Commit

Permalink
Remove mentions of azure logger
Browse files Browse the repository at this point in the history
This gave the impression that we were logging all usage to azure, which
is not the case. Also fixed a bug where only a single plugin could
register a logging handle.
  • Loading branch information
oyvindeide committed Dec 16, 2024
1 parent 1af592d commit aeb324a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
11 changes: 4 additions & 7 deletions src/everest/bin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from everest.bin.kill_script import kill_entry
from everest.bin.monitor_script import monitor_entry
from everest.bin.visualization_script import visualization_entry
from everest.util import get_azure_logging_handler
from everest.plugins.everest_plugin_manager import EverestPluginManager


def _create_dump_action(dumps, extended=False):
Expand Down Expand Up @@ -86,12 +86,9 @@ def __init__(self, args):
if not hasattr(self, parsed_args.command):
parser.error("Unrecognized command")

# Setup logging to azure:
logger = logging.getLogger("everest_main")
azure_handler = get_azure_logging_handler()
if azure_handler:
logger.addHandler(azure_handler)

# Setup logging from plugins:
EverestPluginManager().add_log_handle_to_root()
logger = logging.getLogger(__name__)
logger.info(f"Started everest with {parsed_args}")
# Use dispatch pattern to invoke method with same name
getattr(self, parsed_args.command)(args[2:])
Expand Down
11 changes: 3 additions & 8 deletions src/everest/detached/jobs/everserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from everest.config import EverestConfig, ServerConfig
from everest.detached import ServerStatus, get_opt_status, update_everserver_status
from everest.export import check_for_errors
from everest.plugins.everest_plugin_manager import EverestPluginManager
from everest.simulator import JOB_FAILURE
from everest.strings import (
DEFAULT_LOGGING_FORMAT,
Expand All @@ -48,7 +49,7 @@
SIM_PROGRESS_ENDPOINT,
STOP_ENDPOINT,
)
from everest.util import get_azure_logging_handler, makedirs_if_needed, version_info
from everest.util import makedirs_if_needed, version_info


def _get_machine_name() -> str:
Expand Down Expand Up @@ -208,12 +209,6 @@ def make_handler_config(
"filename": path,
}

def azure_handler():
azure_handler = get_azure_logging_handler()
if azure_handler:
return azure_handler
return logging.NullHandler()

logging_config = {
"version": 1,
"disable_existing_loggers": False,
Expand All @@ -225,7 +220,6 @@ def azure_handler():
"forward_models": make_handler_config(
log_dir / "forward_models.log", logging_level
),
"azure_handler": {"()": azure_handler},
},
"loggers": {
"": {"handlers": ["root"], "level": "NOTSET"},
Expand All @@ -240,6 +234,7 @@ def azure_handler():
}

logging.config.dictConfig(logging_config)
EverestPluginManager().add_log_handle_to_root()


def main():
Expand Down
6 changes: 6 additions & 0 deletions src/everest/plugins/everest_plugin_manager.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import Any

import pluggy
Expand All @@ -20,3 +21,8 @@ def __init__(self, plugins=None) -> None:
def get_documentation(self) -> dict[str, Any]:
docs = self.hook.get_forward_model_documentations()
return {k: v for d in docs for k, v in d.items()} if docs else {}

def add_log_handle_to_root(self):
root_logger = logging.getLogger()
for handler in self.hook.add_log_handle_to_root():
root_logger.addHandler(handler)

0 comments on commit aeb324a

Please sign in to comment.