Skip to content

Commit

Permalink
Add alog protocol support
Browse files Browse the repository at this point in the history
Signed-off-by: Mynhardt Burger <Mynhardt.Burger@ibm.com>
  • Loading branch information
mynhardtburger committed Apr 15, 2024
1 parent 00ea569 commit 0130ad3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions caikit/core/exceptions/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
# Standard
from collections.abc import Iterable
from types import GeneratorType
from typing import TYPE_CHECKING, Dict, NoReturn, Optional, Type
from typing import TYPE_CHECKING, Dict, NoReturn, Optional, Type, Union
import os
import typing

# First Party
from alog.protocols import LoggerProtocol

# Local
from caikit.config import get_config

Expand All @@ -38,7 +41,7 @@
_error_handlers: Dict[str, "ErrorHandler"] = {}


def get(log_chan: "Logger"):
def get(log_chan: Union["Logger", LoggerProtocol]):
"""Get an error handler associated with a given alog log channel. The same error handler will
be returned if this function is called repeatedly with the same log channel.
Expand All @@ -61,7 +64,7 @@ class ErrorHandler:
the `.log_raise` method.
"""

def __init__(self, log_chan: "Logger"):
def __init__(self, log_chan: Union["Logger", LoggerProtocol]):
"""Create a new error handler that provides reusable error checking and automatic logging.
Args:
Expand Down

0 comments on commit 0130ad3

Please sign in to comment.