Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out azure.monitor logs from terminal output #10004

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/ert/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pathlib
import sys
from collections.abc import Callable
from datetime import datetime
from types import TracebackType
from typing import Any
Expand Down Expand Up @@ -74,3 +75,15 @@ def formatException(
| tuple[None, None, None],
) -> str:
return ""


def suppresse_logs(logs_to_suppress: list[str]) -> Callable[[logging.LogRecord], bool]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo suppresse -> suppress?

"""Suppresses logs from loggers listed in logs_to_suppress"""

def filter(record: logging.LogRecord) -> bool:
for log_name in logs_to_suppress:
if record.name.startswith(log_name):
return False
return True

return filter
5 changes: 5 additions & 0 deletions src/ert/logging/storage_log.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ formatters:
format: '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
info:
format: '%(message)s'
filters:
suppress_not_user_relevant:
(): ert.logging.suppresse_logs
logs_to_suppress: [azure.monitor]
handlers:
default:
level: WARNING
formatter: standard
class: logging.StreamHandler
stream: ext://sys.stdout
filters: [suppress_not_user_relevant]
infohandler:
level: INFO
formatter: info
Expand Down