Skip to content

Commit 0b01c48

Browse files
committed
Allow *args.
1 parent c0586cc commit 0b01c48

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

sdks/python/apache_beam/utils/logger.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def _find_caller() -> tuple[str, tuple]:
5656
def log_first_n(
5757
lvl: int,
5858
msg: str,
59+
*args,
5960
n: int = 1,
60-
*,
6161
name: Optional[str] = None,
6262
key: Union[str, tuple[str]] = "caller") -> None:
6363
"""
@@ -93,11 +93,11 @@ def log_first_n(
9393

9494
_LOG_COUNTER[hash_key] += 1
9595
if _LOG_COUNTER[hash_key] <= n:
96-
logging.getLogger(name or caller_module).log(lvl, msg)
96+
logging.getLogger(name or caller_module).log(lvl, msg, *args)
9797

9898

9999
def log_every_n(
100-
lvl: int, msg: str, n: int = 1, *, name: Optional[str] = None) -> None:
100+
lvl: int, msg: str, *args, n: int = 1, name: Optional[str] = None) -> None:
101101
"""
102102
Log once per n times.
103103
@@ -111,11 +111,11 @@ def log_every_n(
111111
caller_module, key = _find_caller()
112112
_LOG_COUNTER[key] += 1
113113
if n == 1 or _LOG_COUNTER[key] % n == 1:
114-
logging.getLogger(name or caller_module).log(lvl, msg)
114+
logging.getLogger(name or caller_module).log(lvl, msg, *args)
115115

116116

117117
def log_every_n_seconds(
118-
lvl: int, msg: str, n: int = 1, *, name: Optional[str] = None) -> None:
118+
lvl: int, msg: str, *args, n: int = 1, name: Optional[str] = None) -> None:
119119
"""
120120
Log no more than once per n seconds.
121121
@@ -130,5 +130,5 @@ def log_every_n_seconds(
130130
last_logged = _LOG_TIMER.get(key, None)
131131
current_time = time.time()
132132
if last_logged is None or current_time - last_logged >= n:
133-
logging.getLogger(name or caller_module).log(lvl, msg)
133+
logging.getLogger(name or caller_module).log(lvl, msg, *args)
134134
_LOG_TIMER[key] = current_time

0 commit comments

Comments
 (0)