Print the message if the llmapi debug mode is enabled. Fallback to logger.debug if not.
(message,
color: Optional[str] = None,
writer: io.TextIOWrapper = sys.stderr)
| 104 | |
| 105 | |
| 106 | def logger_debug(message, |
| 107 | color: Optional[str] = None, |
| 108 | writer: io.TextIOWrapper = sys.stderr): |
| 109 | """ Print the message if the llmapi debug mode is enabled. Fallback to logger.debug if not. """ |
| 110 | if enable_llmapi_debug(): |
| 111 | timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") |
| 112 | location = get_current_location() |
| 113 | cur_dualname = "..." + location[-47:] if len( |
| 114 | location) > 50 else location |
| 115 | print_colored(f"{timestamp} [{cur_dualname}]", "bold_green", writer) |
| 116 | print_colored(f" {message}\n", color, writer) |
| 117 | writer.flush() |
| 118 | else: |
| 119 | # Fallback to logger.debug |
| 120 | logger.debug(message) |
| 121 | |
| 122 | |
| 123 | def file_with_glob_exists(directory, glob) -> bool: |