Skip to content
Merged
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
2 changes: 1 addition & 1 deletion ocp_resources/event.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ocp_resources.logger import get_logger
from simple_logger.logger import get_logger

LOGGER = get_logger(name=__name__)

Expand Down
75 changes: 0 additions & 75 deletions ocp_resources/logger.py

This file was deleted.

13 changes: 11 additions & 2 deletions ocp_resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from openshift.dynamic.exceptions import ConflictError, NotFoundError
from openshift.dynamic.resource import ResourceField
from packaging.version import Version
from simple_logger.logger import get_logger

from ocp_resources.constants import (
DEFAULT_CLUSTER_RETRY_EXCEPTIONS,
Expand All @@ -22,7 +23,6 @@
TIMEOUT_4MINUTES,
)
from ocp_resources.event import Event
from ocp_resources.logger import get_logger
from ocp_resources.utils import (
TimeoutExpiredError,
TimeoutSampler,
Expand Down Expand Up @@ -364,10 +364,19 @@ def __init__(
self.res = None
self.yaml_file_contents = None
self.initial_resource_version = None
self.logger = get_logger(name=f"{__name__.rsplit('.')[0]} {self.kind}")
self.logger = self._set_logger()
self.timeout_seconds = timeout_seconds
self._set_client_and_api_version()

def _set_logger(self):
log_level = os.environ.get("OPENSHIFT_PYTHON_WRAPPER_LOG_LEVEL", "INFO")
log_file = os.environ.get("OPENSHIFT_PYTHON_WRAPPER_LOG_FILE", "")
return get_logger(
name=f"{__name__.rsplit('.')[0]} {self.kind}",
level=log_level,
filename=log_file,
)

def _prepare_node_selector_spec(self):
if self.node_selector:
return {f"{self.ApiGroup.KUBERNETES_IO}/hostname": self.node_selector}
Expand Down
3 changes: 1 addition & 2 deletions ocp_resources/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import time

import yaml

from ocp_resources.logger import get_logger
from simple_logger.logger import get_logger

LOGGER = get_logger(name=__name__)

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ dependencies = [
"urllib3",
"colorlog",
"packaging",
"kubernetes",
"python-simple-logger",
]
dynamic = ["version"]
# ...
Expand Down