|
4 | 4 | import os
|
5 | 5 | import random
|
6 | 6 | import sys
|
7 |
| -from typing import IO, Any, Callable, Dict, Iterable, Optional, TypeVar, Union |
| 7 | +from typing import IO, Any, Callable, Dict, Iterable, Mapping, Optional, TypeVar, Union |
8 | 8 |
|
9 | 9 | import jmespath
|
10 | 10 |
|
@@ -359,6 +359,101 @@ def decorate(event, context, *args, **kwargs):
|
359 | 359 |
|
360 | 360 | return decorate
|
361 | 361 |
|
| 362 | + def info( |
| 363 | + self, |
| 364 | + msg: object, |
| 365 | + *args, |
| 366 | + exc_info=None, |
| 367 | + stack_info: bool = False, |
| 368 | + stacklevel: int = 2, |
| 369 | + extra: Optional[Mapping[str, object]] = None, |
| 370 | + **kwargs, |
| 371 | + ): |
| 372 | + # NOTE: We need to solve stack frame location for Python <3.8 |
| 373 | + extra = extra or {} |
| 374 | + extra = {**extra, **kwargs} |
| 375 | + if sys.version_info < (3, 8): |
| 376 | + return self._logger.info(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra) |
| 377 | + return self._logger.info( |
| 378 | + msg, *args, exc_info=exc_info, stack_info=stack_info, stacklevel=stacklevel, extra=extra |
| 379 | + ) |
| 380 | + |
| 381 | + def error( |
| 382 | + self, |
| 383 | + msg: object, |
| 384 | + *args, |
| 385 | + exc_info=None, |
| 386 | + stack_info: bool = False, |
| 387 | + stacklevel: int = 2, |
| 388 | + extra: Optional[Mapping[str, object]] = None, |
| 389 | + **kwargs, |
| 390 | + ): |
| 391 | + # NOTE: We need to solve stack frame location for Python <3.8 |
| 392 | + extra = extra or {} |
| 393 | + extra = {**extra, **kwargs} |
| 394 | + if sys.version_info < (3, 8): |
| 395 | + return self._logger.error(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra) |
| 396 | + return self._logger.error( |
| 397 | + msg, *args, exc_info=exc_info, stack_info=stack_info, stacklevel=stacklevel, extra=extra |
| 398 | + ) |
| 399 | + |
| 400 | + def exception( |
| 401 | + self, |
| 402 | + msg: object, |
| 403 | + *args, |
| 404 | + exc_info=None, |
| 405 | + stack_info: bool = False, |
| 406 | + stacklevel: int = 2, |
| 407 | + extra: Optional[Mapping[str, object]] = None, |
| 408 | + **kwargs, |
| 409 | + ): |
| 410 | + # NOTE: We need to solve stack frame location for Python <3.8 |
| 411 | + extra = extra or {} |
| 412 | + extra = {**extra, **kwargs} |
| 413 | + if sys.version_info < (3, 8): |
| 414 | + return self._logger.exception(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra) |
| 415 | + return self._logger.exception( |
| 416 | + msg, *args, exc_info=exc_info, stack_info=stack_info, stacklevel=stacklevel, extra=extra |
| 417 | + ) |
| 418 | + |
| 419 | + def critical( |
| 420 | + self, |
| 421 | + msg: object, |
| 422 | + *args, |
| 423 | + exc_info=None, |
| 424 | + stack_info: bool = False, |
| 425 | + stacklevel: int = 2, |
| 426 | + extra: Optional[Mapping[str, object]] = None, |
| 427 | + **kwargs, |
| 428 | + ): |
| 429 | + # NOTE: We need to solve stack frame location for Python <3.8 |
| 430 | + extra = extra or {} |
| 431 | + extra = {**extra, **kwargs} |
| 432 | + if sys.version_info < (3, 8): |
| 433 | + return self._logger.critical(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra) |
| 434 | + return self._logger.critical( |
| 435 | + msg, *args, exc_info=exc_info, stack_info=stack_info, stacklevel=stacklevel, extra=extra |
| 436 | + ) |
| 437 | + |
| 438 | + def warning( |
| 439 | + self, |
| 440 | + msg: object, |
| 441 | + *args, |
| 442 | + exc_info=None, |
| 443 | + stack_info: bool = False, |
| 444 | + stacklevel: int = 2, |
| 445 | + extra: Optional[Mapping[str, object]] = None, |
| 446 | + **kwargs, |
| 447 | + ): |
| 448 | + # NOTE: We need to solve stack frame location for Python <3.8 |
| 449 | + extra = extra or {} |
| 450 | + extra = {**extra, **kwargs} |
| 451 | + if sys.version_info < (3, 8): |
| 452 | + return self._logger.warning(msg, *args, exc_info=exc_info, stack_info=stack_info, extra=extra) |
| 453 | + return self._logger.warning( |
| 454 | + msg, *args, exc_info=exc_info, stack_info=stack_info, stacklevel=stacklevel, extra=extra |
| 455 | + ) |
| 456 | + |
362 | 457 | def append_keys(self, **additional_keys):
|
363 | 458 | self.registered_formatter.append_keys(**additional_keys)
|
364 | 459 |
|
|
0 commit comments