logging_utils.py 487 B

123456789101112131415
  1. from __future__ import annotations
  2. from datetime import datetime
  3. import builtins
  4. from typing import Any
  5. def log_print(*args: Any, **kwargs: Any) -> None:
  6. sep = kwargs.get("sep", " ")
  7. end = kwargs.get("end", "\n")
  8. file = kwargs.get("file", None)
  9. flush = kwargs.get("flush", False)
  10. message = sep.join(str(arg) for arg in args)
  11. timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  12. builtins.print(f"{timestamp} {message}", end=end, file=file, flush=flush)