Skip to content

Conversation

@Windsland52
Copy link
Member

@Windsland52 Windsland52 commented Jan 14, 2026

@MistEO 康康

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮换,而不是在可能已损坏的备份基础上继续进行。
  • 在日志文件打开失败时,将错误输出到 stderr,并将日志记录器的流保持在关闭状态,避免使用无效的日志记录器。

增强:

  • 为单条日志记录强制设置最大大小,对超长消息进行截断并添加诊断性后缀,以防止过度或损坏的日志输出。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验证件输出流;当日志流无效时将信息输出到 stderr,以避免日志条目被悄然丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮转,而不是在可能已损坏的备份基础上继续处理。
  • 在打开日志文件失败时,通过将错误报告到 stderr 并跳过日志记录器初始化来优雅地处理,而不是在无效状态下继续运行。

增强功能:

  • 为单个日志条目强制设定最大大小,对超过限制的消息进行截断,并附带清晰的诊断说明,以防止日志输出过大或损坏。
  • 在写入日志文件前对输出流进行校验进行保护,如发现无效则先报告到 stderr,以避免悄然丢失日志条目。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮换,而不是在可能已损坏的备份基础上继续进行。
  • 在日志文件打开失败时,将错误输出到 stderr,并将日志记录器的流保持在关闭状态,避免使用无效的日志记录器。

增强:

  • 为单条日志记录强制设置最大大小,对超长消息进行截断并添加诊断性后缀,以防止过度或损坏的日志输出。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验证件输出流;当日志流无效时将信息输出到 stderr,以避免日志条目被悄然丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径时发生失败时,终止日志轮转,防止生成损坏的备份文件。
  • 当打开日志文件失败时,将错误输出到 stderr,并跳过日志记录器初始化,而不是在异常状态下继续运行。

增强功能:

  • 限制单条日志消息的最大大小,对超长日志进行截断,并附加清晰的诊断说明,以避免产生过多或损坏的日志输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮换,而不是在可能已损坏的备份基础上继续进行。
  • 在日志文件打开失败时,将错误输出到 stderr,并将日志记录器的流保持在关闭状态,避免使用无效的日志记录器。

增强:

  • 为单条日志记录强制设置最大大小,对超长消息进行截断并添加诊断性后缀,以防止过度或损坏的日志输出。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验证件输出流;当日志流无效时将信息输出到 stderr,以避免日志条目被悄然丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮转,而不是在可能已损坏的备份基础上继续处理。
  • 在打开日志文件失败时,通过将错误报告到 stderr 并跳过日志记录器初始化来优雅地处理,而不是在无效状态下继续运行。

增强功能:

  • 为单个日志条目强制设定最大大小,对超过限制的消息进行截断,并附带清晰的诊断说明,以防止日志输出过大或损坏。
  • 在写入日志文件前对输出流进行校验进行保护,如发现无效则先报告到 stderr,以避免悄然丢失日志条目。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮换,而不是在可能已损坏的备份基础上继续进行。
  • 在日志文件打开失败时,将错误输出到 stderr,并将日志记录器的流保持在关闭状态,避免使用无效的日志记录器。

增强:

  • 为单条日志记录强制设置最大大小,对超长消息进行截断并添加诊断性后缀,以防止过度或损坏的日志输出。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验证件输出流;当日志流无效时将信息输出到 stderr,以避免日志条目被悄然丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 在轮转过程中复制日志文件失败时进行处理,并在出现错误时中止轮转。
  • 在打开日志文件失败时进行优雅处理:将错误报告到 stderr,并跳过日志记录器的初始化。

增强功能:

  • 限制单条日志记录的最大大小,对于过大的消息进行截断,并附上清晰的诊断说明。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮换,而不是在可能已损坏的备份基础上继续进行。
  • 在日志文件打开失败时,将错误输出到 stderr,并将日志记录器的流保持在关闭状态,避免使用无效的日志记录器。

增强:

  • 为单条日志记录强制设置最大大小,对超长消息进行截断并添加诊断性后缀,以防止过度或损坏的日志输出。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验证件输出流;当日志流无效时将信息输出到 stderr,以避免日志条目被悄然丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮转,而不是在可能已损坏的备份基础上继续处理。
  • 在打开日志文件失败时,通过将错误报告到 stderr 并跳过日志记录器初始化来优雅地处理,而不是在无效状态下继续运行。

增强功能:

  • 为单个日志条目强制设定最大大小,对超过限制的消息进行截断,并附带清晰的诊断说明,以防止日志输出过大或损坏。
  • 在写入日志文件前对输出流进行校验进行保护,如发现无效则先报告到 stderr,以避免悄然丢失日志条目。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮换,而不是在可能已损坏的备份基础上继续进行。
  • 在日志文件打开失败时,将错误输出到 stderr,并将日志记录器的流保持在关闭状态,避免使用无效的日志记录器。

增强:

  • 为单条日志记录强制设置最大大小,对超长消息进行截断并添加诊断性后缀,以防止过度或损坏的日志输出。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验证件输出流;当日志流无效时将信息输出到 stderr,以避免日志条目被悄然丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径时发生失败时,终止日志轮转,防止生成损坏的备份文件。
  • 当打开日志文件失败时,将错误输出到 stderr,并跳过日志记录器初始化,而不是在异常状态下继续运行。

增强功能:

  • 限制单条日志消息的最大大小,对超长日志进行截断,并附加清晰的诊断说明,以避免产生过多或损坏的日志输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮换,而不是在可能已损坏的备份基础上继续进行。
  • 在日志文件打开失败时,将错误输出到 stderr,并将日志记录器的流保持在关闭状态,避免使用无效的日志记录器。

增强:

  • 为单条日志记录强制设置最大大小,对超长消息进行截断并添加诊断性后缀,以防止过度或损坏的日志输出。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验证件输出流;当日志流无效时将信息输出到 stderr,以避免日志条目被悄然丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮转,而不是在可能已损坏的备份基础上继续处理。
  • 在打开日志文件失败时,通过将错误报告到 stderr 并跳过日志记录器初始化来优雅地处理,而不是在无效状态下继续运行。

增强功能:

  • 为单个日志条目强制设定最大大小,对超过限制的消息进行截断,并附带清晰的诊断说明,以防止日志输出过大或损坏。
  • 在写入日志文件前对输出流进行校验进行保护,如发现无效则先报告到 stderr,以避免悄然丢失日志条目。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Bug 修复:

  • 当将现有日志文件复制到备份路径失败时,中止日志轮换,而不是在可能已损坏的备份基础上继续进行。
  • 在日志文件打开失败时,将错误输出到 stderr,并将日志记录器的流保持在关闭状态,避免使用无效的日志记录器。

增强:

  • 为单条日志记录强制设置最大大小,对超长消息进行截断并添加诊断性后缀,以防止过度或损坏的日志输出。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验证件输出流;当日志流无效时将信息输出到 stderr,以避免日志条目被悄然丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录和日志轮转的健壮性与安全性。

错误修复:

  • 当将现有日志文件复制到备份路径失败时中止日志轮转,避免使用可能已损坏的备份文件。
  • 在打开日志文件失败时,将错误报告到 stderr,并保持日志输出流关闭状态,而不是使用无效的日志记录器。

改进:

  • 为单条日志记录设定最大大小限制,对超长消息进行截断,并附加诊断性后缀,以防止日志输出过大或被破坏。
  • 对于超长日志条目跳过 stdout 日志输出,并在写入前校验文件流的有效性;如果日志流无效,则回退到 stderr 输出。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:通过向 stderr 报告错误并保持 logger 流处于关闭状态,而不是在无效的流上继续执行。

功能增强:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断并附加诊断性后缀;对于过大的日志条目,跳过输出到 stdout,以防止控制台被大量信息刷屏。
  • 在写入之前验证日志文件流的有效性,并在流无效或已关闭时向 stderr 报告,以避免静默丢失日志记录。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

错误修复:

  • 当将当前日志文件复制到备份路径失败时中止日志轮换,避免使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况,将详细错误信息输出到 stderr,并保持日志流处于关闭状态,而不是在记录器无效的情况下继续运行。

增强功能:

  • 对单条日志记录强制执行最大大小限制,对超长消息进行截断,并附加诊断性后缀;对于过大的日志记录,跳过其 stdout 输出。
  • 在写入之前验证日志文件输出流状态,如发现流无效或已关闭,则将错误报告到 stderr,以防止日志条目被静默丢失。
Original summary in English

由 Sourcery 提供的摘要

提升基于文件的日志记录及日志轮转的健壮性与安全性。

错误修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,防止使用可能已损坏的备份文件。
  • 处理打开日志文件失败的情况:将详细错误信息记录到 stderr,并保持日志流关闭状态,而不是继续使用无效的 logger。

改进增强:

  • 为单条日志记录引入大小限制,对超出大小的消息进行截断,并附加诊断性后缀;当消息超出最大大小时跳过输出到 stdout。
  • 在写入前验证日志文件输出流的有效性,并将问题报告到 stderr,以避免日志条目被静默丢失。
Original summary in English

Summary by Sourcery

改进基于文件的日志记录和日志轮转在处理大型日志条目和文件 I/O 失败时的健壮性和安全性。

Bug 修复:

  • 当将当前日志文件复制到备份路径失败时,中止日志轮转,而不是继续使用可能已损坏的备份文件。
  • 处理日志文件打开失败时,将详细错误报告到 stderr,并确保文件流保持在关闭且安全的状态。

增强功能:

  • 引入可配置的单条日志最大大小限制,对超长消息进行截断并附加诊断后缀,以避免过度或损坏的输出。
  • 对过大的日志条目跳过 stdout 输出,并在写入前校验日志文件输出流的有效性;当流无效时回退到 stderr。
Original summary in English

Summary by Sourcery

Improve robustness and safety of file-based logging and log rotation around large log entries and file I/O failures.

Bug Fixes:

  • Abort log rotation when copying the current log file to the backup path fails, instead of proceeding with a potentially corrupted backup.
  • Handle log file open failures by reporting detailed errors to stderr and leaving the file stream in a closed, safe state.

Enhancements:

  • Introduce configurable maximum size limits for individual log entries, truncating oversized messages with a diagnostic suffix to avoid excessive or corrupted output.
  • Skip stdout output for overly large log entries and validate the log file output stream before writing, falling back to stderr when the stream is invalid.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些总体反馈:

  • LogStream 中,在调用 stdout_string() 之前就把 buffer_ 移动到 content 中,有可能会让 stdout_string() 遇到一个空或无效的缓冲区;建议将 std::move(buffer_) 延后到所有对 buffer_ 的使用(例如 stdout 输出)完成之后再进行。
  • 在截断 content 时,substr(0, 1024) 中硬编码的 1024kMaxLogSize 不一致;请始终使用 kMaxLogSize(或一个专门的常量),以避免在限制更新时出现不一致。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- In `LogStream`, moving `buffer_` into `content` before calling `stdout_string()` risks leaving `stdout_string()` with an empty/invalid buffer; consider deferring the `std::move(buffer_)` until after any uses of `buffer_` (e.g., for stdout output).
- When truncating `content`, the hardcoded `1024` in `substr(0, 1024)` does not match `kMaxLogSize`; use `kMaxLogSize` (or a dedicated constant) consistently to avoid discrepancies if the limit is updated.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:76-85` </location>
<code_context>
     {
         std::unique_lock lock(mutex_);

+        auto content = std::move(buffer_).str();
+
+        // Prevent writing excessive data (likely a bug if > 1MB)
+        constexpr size_t kMaxLogSize = 1024 * 1024; // 1MB
+        if (content.size() > kMaxLogSize) {
+            content = content.substr(0, 1024) +
+                      std::format(" ... [TRUNCATED: {} bytes total, likely a bug - check for large objects passed to logger]",
+                                  content.size());
+        }
+
         if (stdout_) {
             std::cout << stdout_string() << std::endl;
         }
</code_context>

<issue_to_address>
**issue (bug_risk):** Moving from buffer_ before stdout_ logging likely breaks stdout output

`stdout_string()` likely reads from `buffer_`, but `buffer_` has already been moved-from when constructing `content`, so stdout may log empty/invalid data while the file gets the correct `content`. Please either build `content` without moving (e.g. `buffer_.str()`) or have both stdout and file output use `content` instead of `buffer_`.
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In LogStream, moving buffer_ into content before calling stdout_string() risks leaving stdout_string() with an empty/invalid buffer; consider deferring the std::move(buffer_) until after any uses of buffer_ (e.g., for stdout output).
  • When truncating content, the hardcoded 1024 in substr(0, 1024) does not match kMaxLogSize; use kMaxLogSize (or a dedicated constant) consistently to avoid discrepancies if the limit is updated.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `LogStream`, moving `buffer_` into `content` before calling `stdout_string()` risks leaving `stdout_string()` with an empty/invalid buffer; consider deferring the `std::move(buffer_)` until after any uses of `buffer_` (e.g., for stdout output).
- When truncating `content`, the hardcoded `1024` in `substr(0, 1024)` does not match `kMaxLogSize`; use `kMaxLogSize` (or a dedicated constant) consistently to avoid discrepancies if the limit is updated.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:76-85` </location>
<code_context>
     {
         std::unique_lock lock(mutex_);

+        auto content = std::move(buffer_).str();
+
+        // Prevent writing excessive data (likely a bug if > 1MB)
+        constexpr size_t kMaxLogSize = 1024 * 1024; // 1MB
+        if (content.size() > kMaxLogSize) {
+            content = content.substr(0, 1024) +
+                      std::format(" ... [TRUNCATED: {} bytes total, likely a bug - check for large objects passed to logger]",
+                                  content.size());
+        }
+
         if (stdout_) {
             std::cout << stdout_string() << std::endl;
         }
</code_context>

<issue_to_address>
**issue (bug_risk):** Moving from buffer_ before stdout_ logging likely breaks stdout output

`stdout_string()` likely reads from `buffer_`, but `buffer_` has already been moved-from when constructing `content`, so stdout may log empty/invalid data while the file gets the correct `content`. Please either build `content` without moving (e.g. `buffer_.str()`) or have both stdout and file output use `content` instead of `buffer_`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Member Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并且给出了一些高层次的反馈:

  • LogStream 中使用 std::format 会引入对 C++20 的依赖,并在高频日志路径上增加一个可能抛异常的点;建议要么显式包含 <format> 并将调用包在 try/catch 中(避免异常向外逃出日志器),要么使用不会抛异常的格式化替代方案。
  • Logger::open 中,当 fopen 失败时,你只写了一条信息到 stderr 然后直接返回;更安全的做法可能是显式地把 logger 标记为已禁用,或者确保后续对 ofs_ 的所有使用都有防护,这样日志调用就不会在静默的前提下假设流一定有效。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
-`LogStream` 中使用 `std::format` 会引入对 C++20 的依赖,并在高频日志路径上增加一个可能抛异常的点;建议要么显式包含 `<format>` 并将调用包在 `try`/`catch` 中(避免异常向外逃出日志器),要么使用不会抛异常的格式化替代方案。
-`Logger::open` 中,当 `fopen` 失败时,你只写了一条信息到 `stderr` 然后直接返回;更安全的做法可能是显式地把 logger 标记为已禁用,或者确保后续对 `ofs_` 的所有使用都有防护,这样日志调用就不会在静默的前提下假设流一定有效。

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:76-82` </location>
<code_context>
     {
         std::unique_lock lock(mutex_);

+        // Output to stdout first (while buffer_ is still valid)
         if (stdout_) {
             std::cout << stdout_string() << std::endl;
         }
-        stream_ << std::move(buffer_).str() << std::endl;
+
+        // Now get content and apply size limit
+        auto content = std::move(buffer_).str();
+
+        // Prevent writing excessive data (likely a bug if > 1MB)
</code_context>

<issue_to_address>
**question (bug_risk):** Large log entries are still fully written to stdout even when truncated for the main stream.

Size limit 目前只应用在 `stream_` 上;`stdout_` 仍然会接收到完整的 `stdout_string()` 内容。如果目标是避免在任何地方输出非常大的负载,建议对 stdout 也应用同样的限制,或者说明为什么 stdout 是有意不受限制的。按当前实现,同一次日志调用仍然可能淹没 stdout,而文件日志却只写入被截断后的内容。
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享它们 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • Using std::format in LogStream introduces a C++20 dependency and a potential throw point in a hot logging path; consider either including <format> explicitly and wrapping the call in a try/catch (to avoid exceptions escaping the logger) or using a non-throwing formatting alternative.
  • In Logger::open, when fopen fails you only write to stderr and return; it may be safer to explicitly mark the logger as disabled or ensure all later uses of ofs_ are guarded so that logging calls don’t silently assume a valid stream.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Using `std::format` in `LogStream` introduces a C++20 dependency and a potential throw point in a hot logging path; consider either including `<format>` explicitly and wrapping the call in a `try`/`catch` (to avoid exceptions escaping the logger) or using a non-throwing formatting alternative.
- In `Logger::open`, when `fopen` fails you only write to `stderr` and return; it may be safer to explicitly mark the logger as disabled or ensure all later uses of `ofs_` are guarded so that logging calls don’t silently assume a valid stream.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:76-82` </location>
<code_context>
     {
         std::unique_lock lock(mutex_);

+        // Output to stdout first (while buffer_ is still valid)
         if (stdout_) {
             std::cout << stdout_string() << std::endl;
         }
-        stream_ << std::move(buffer_).str() << std::endl;
+
+        // Now get content and apply size limit
+        auto content = std::move(buffer_).str();
+
+        // Prevent writing excessive data (likely a bug if > 1MB)
</code_context>

<issue_to_address>
**question (bug_risk):** Large log entries are still fully written to stdout even when truncated for the main stream.

The size limit is only applied to `stream_`; `stdout_` still receives the full `stdout_string()` content. If the goal is to avoid emitting very large payloads anywhere, consider applying the same limit to stdout, or document why stdout is intentionally exempt. As-is, a single log call can still flood stdout while being truncated only in the file log.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Member Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了两个问题,并给出了一些总体反馈:

  • LogStream::operator<</flush 中,你先调用一次 buffer_.str() 来计算 content_size,然后又通过 std::move(buffer_).str() 再调用一次;建议抽取成一次 std::string content = std::move(buffer_).str();,然后复用 content.size() 做大小检查和输出,从而避免双重分配/拷贝。
  • LogStream 内部硬编码的 kMaxLogSizekTruncatedSize 阈值会让调优变得更难,而且如果在其他地方也需要这些阈值,容易出现不一致;建议把它们提升为类级或文件级常量(或配置项),在单一位置定义、并在各处一致复用。
  • Logger::openfopen 日志文件时失败,目前只是在 stderr 打印一条消息然后返回,而不会更新任何状态;建议显式地标记 logger 已不可用(例如清空/关闭 ofs_ 或增加一个 is_open_ 标志),这样后续的日志调用就能可靠地跳过写入,而不是继续使用已经失效的输出流。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- In `LogStream::operator<<`/flush, you call `buffer_.str()` once to compute `content_size` and then again via `std::move(buffer_).str()`; consider extracting a single `std::string content = std::move(buffer_).str();` and reusing `content.size()` for both the size checks and output to avoid double allocation/copying.
- The hardcoded `kMaxLogSize` and `kTruncatedSize` thresholds inside `LogStream` make tuning harder and risk divergence if used elsewhere; consider promoting them to class- or file-scope constants (or configuration) so they are defined in one place and can be reused consistently.
- When `Logger::open` fails to `fopen` the log file, it currently just prints to `stderr` and returns without updating any state; consider explicitly marking the logger as unusable (e.g., clearing/closing `ofs_` or tracking an `is_open_` flag) so that subsequent logging calls can reliably skip writes instead of using a stale stream.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:74-79` </location>
<code_context>
         std::unique_lock lock(mutex_);

+        // Check size before any output (temporary copy to check size)
+        const size_t content_size = buffer_.str().size();
+        constexpr size_t kMaxLogSize = 1024 * 1024; // 1MB
+        constexpr size_t kTruncatedSize = 1024; // 1KB
+
+        // Output to stdout (skip if too large to avoid flooding console)
         if (stdout_) {
-            std::cout << stdout_string() << std::endl;
+            if (content_size > kMaxLogSize) {
+                std::cerr << "[WARNING: Log entry too large (" << content_size
+                         << " bytes), skipping stdout output]" << std::endl;
+            } else {
+                std::cout << stdout_string() << std::endl;
+            }
+        }
+
+        // Get content and apply size limit for file
+        auto content = std::move(buffer_).str();
+
+        if (content.size() > kMaxLogSize) {
</code_context>

<issue_to_address>
**suggestion (performance):** Avoid double string construction from stringstream by using its size directly (e.g., tellp) or reusing a single materialized string.

`buffer_.str()` is called twice: once to compute `content_size` and again via `std::move(buffer_).str()`, causing two full allocations/copies for large logs. Since the stream is only written to, you can either rely on `buffer_.tellp()` for the size check, or materialize once into a `std::string` and reuse it for both the stdout size check and file output to avoid extra work on the hot path.

```suggestion
        std::unique_lock lock(mutex_);

        // Check size before any output without materializing the string
        const size_t content_size = static_cast<size_t>(buffer_.tellp());
        constexpr size_t kMaxLogSize = 1024 * 1024; // 1MB
        constexpr size_t kTruncatedSize = 1024; // 1KB
```
</issue_to_address>

### Comment 2
<location> `source/Logger/Logger.cpp:164-167` </location>
<code_context>
     // https://stackoverflow.com/questions/55513974/controlling-inheritability-of-file-handles-created-by-c-stdfstream-in-window
     std::string str_log_path = log_path_.string();
     FILE* file_ptr = fopen(str_log_path.c_str(), append ? "a" : "w");
+    if (!file_ptr) {
+        // Failed to open file, log to stderr and return
+        std::cerr << "Failed to open log file: " << str_log_path << std::endl;
+        return;
+    }
     SetHandleInformation((HANDLE)_get_osfhandle(_fileno(file_ptr)), HANDLE_FLAG_INHERIT, 0);
</code_context>

<issue_to_address>
**issue (bug_risk):** On log file open failure, consider resetting/invalidating the existing output stream to avoid writing to a stale handle.

Right now if `fopen` fails we just log to `stderr` and return, leaving `ofs_` unchanged. If this path is used for log rotation or re-open, the logger may keep writing to the old or an invalid stream. Consider explicitly closing/resetting `ofs_` (and possibly recording a failure state) so callers can detect the error and avoid writing to a stale stream.
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈持续改进评审质量。
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • In LogStream::operator<</flush, you call buffer_.str() once to compute content_size and then again via std::move(buffer_).str(); consider extracting a single std::string content = std::move(buffer_).str(); and reusing content.size() for both the size checks and output to avoid double allocation/copying.
  • The hardcoded kMaxLogSize and kTruncatedSize thresholds inside LogStream make tuning harder and risk divergence if used elsewhere; consider promoting them to class- or file-scope constants (or configuration) so they are defined in one place and can be reused consistently.
  • When Logger::open fails to fopen the log file, it currently just prints to stderr and returns without updating any state; consider explicitly marking the logger as unusable (e.g., clearing/closing ofs_ or tracking an is_open_ flag) so that subsequent logging calls can reliably skip writes instead of using a stale stream.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `LogStream::operator<<`/flush, you call `buffer_.str()` once to compute `content_size` and then again via `std::move(buffer_).str()`; consider extracting a single `std::string content = std::move(buffer_).str();` and reusing `content.size()` for both the size checks and output to avoid double allocation/copying.
- The hardcoded `kMaxLogSize` and `kTruncatedSize` thresholds inside `LogStream` make tuning harder and risk divergence if used elsewhere; consider promoting them to class- or file-scope constants (or configuration) so they are defined in one place and can be reused consistently.
- When `Logger::open` fails to `fopen` the log file, it currently just prints to `stderr` and returns without updating any state; consider explicitly marking the logger as unusable (e.g., clearing/closing `ofs_` or tracking an `is_open_` flag) so that subsequent logging calls can reliably skip writes instead of using a stale stream.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:74-79` </location>
<code_context>
         std::unique_lock lock(mutex_);

+        // Check size before any output (temporary copy to check size)
+        const size_t content_size = buffer_.str().size();
+        constexpr size_t kMaxLogSize = 1024 * 1024; // 1MB
+        constexpr size_t kTruncatedSize = 1024; // 1KB
+
+        // Output to stdout (skip if too large to avoid flooding console)
         if (stdout_) {
-            std::cout << stdout_string() << std::endl;
+            if (content_size > kMaxLogSize) {
+                std::cerr << "[WARNING: Log entry too large (" << content_size
+                         << " bytes), skipping stdout output]" << std::endl;
+            } else {
+                std::cout << stdout_string() << std::endl;
+            }
+        }
+
+        // Get content and apply size limit for file
+        auto content = std::move(buffer_).str();
+
+        if (content.size() > kMaxLogSize) {
</code_context>

<issue_to_address>
**suggestion (performance):** Avoid double string construction from stringstream by using its size directly (e.g., tellp) or reusing a single materialized string.

`buffer_.str()` is called twice: once to compute `content_size` and again via `std::move(buffer_).str()`, causing two full allocations/copies for large logs. Since the stream is only written to, you can either rely on `buffer_.tellp()` for the size check, or materialize once into a `std::string` and reuse it for both the stdout size check and file output to avoid extra work on the hot path.

```suggestion
        std::unique_lock lock(mutex_);

        // Check size before any output without materializing the string
        const size_t content_size = static_cast<size_t>(buffer_.tellp());
        constexpr size_t kMaxLogSize = 1024 * 1024; // 1MB
        constexpr size_t kTruncatedSize = 1024; // 1KB
```
</issue_to_address>

### Comment 2
<location> `source/Logger/Logger.cpp:164-167` </location>
<code_context>
     // https://stackoverflow.com/questions/55513974/controlling-inheritability-of-file-handles-created-by-c-stdfstream-in-window
     std::string str_log_path = log_path_.string();
     FILE* file_ptr = fopen(str_log_path.c_str(), append ? "a" : "w");
+    if (!file_ptr) {
+        // Failed to open file, log to stderr and return
+        std::cerr << "Failed to open log file: " << str_log_path << std::endl;
+        return;
+    }
     SetHandleInformation((HANDLE)_get_osfhandle(_fileno(file_ptr)), HANDLE_FLAG_INHERIT, 0);
</code_context>

<issue_to_address>
**issue (bug_risk):** On log file open failure, consider resetting/invalidating the existing output stream to avoid writing to a stale handle.

Right now if `fopen` fails we just log to `stderr` and return, leaving `ofs_` unchanged. If this path is used for log rotation or re-open, the logger may keep writing to the old or an invalid stream. Consider explicitly closing/resetting `ofs_` (and possibly recording a failure state) so callers can detect the error and avoid writing to a stale stream.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Member Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些高层面的反馈:

  • LogStream::flush 中,调用 std::move(buffer_).str() 依赖于一个已被移动的 std::stringstream 的状态;更安全、也更清晰的做法是通过 auto content = buffer_.str(); 获取字符串,然后重置 buffer(例如 buffer_.str(""); buffer_.clear();)。
  • 当通过 buffer_.tellp() 推导 content_size 时,建议处理 tellp() 返回 std::streampos(-1)(失败)的情况,因为当前的 static_cast<size_t> 会把它变成一个非常大的值,从而错误地触发超大日志分支。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- In `LogStream::flush`, calling `std::move(buffer_).str()` relies on the state of a moved-from `std::stringstream`; it would be safer and clearer to get the string via `auto content = buffer_.str();` and then reset the buffer (e.g. `buffer_.str(""); buffer_.clear();`).
- When deriving `content_size` from `buffer_.tellp()`, consider handling the case where `tellp()` returns `std::streampos(-1)` (failure), as the current `static_cast<size_t>` could turn this into a very large size and incorrectly trigger the oversized-log path.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:77` </location>
<code_context>
         std::unique_lock lock(mutex_);

+        // Check size before any output without materializing the string
+        const size_t content_size = static_cast<size_t>(buffer_.tellp());
+
+        // Output to stdout (skip if too large to avoid flooding console)
</code_context>

<issue_to_address>
**issue (bug_risk):** Guard against `tellp()` failure before casting to `size_t` for size checks.

`buffer_.tellp()` can return `pos_type(-1)` on failure, which becomes a huge `size_t` and will always trip the "too large" check with an incorrect byte count. Consider capturing the result first and handling errors before casting, e.g.:

```cpp
auto pos = buffer_.tellp();
if (pos < 0) {
    // handle failure: skip size check, use content.size(), or treat as error
}
size_t content_size = static_cast<size_t>(pos);
```

At minimum, treat negative positions as an explicit error case instead of casting directly.
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In LogStream::flush, calling std::move(buffer_).str() relies on the state of a moved-from std::stringstream; it would be safer and clearer to get the string via auto content = buffer_.str(); and then reset the buffer (e.g. buffer_.str(""); buffer_.clear();).
  • When deriving content_size from buffer_.tellp(), consider handling the case where tellp() returns std::streampos(-1) (failure), as the current static_cast<size_t> could turn this into a very large size and incorrectly trigger the oversized-log path.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `LogStream::flush`, calling `std::move(buffer_).str()` relies on the state of a moved-from `std::stringstream`; it would be safer and clearer to get the string via `auto content = buffer_.str();` and then reset the buffer (e.g. `buffer_.str(""); buffer_.clear();`).
- When deriving `content_size` from `buffer_.tellp()`, consider handling the case where `tellp()` returns `std::streampos(-1)` (failure), as the current `static_cast<size_t>` could turn this into a very large size and incorrectly trigger the oversized-log path.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:77` </location>
<code_context>
         std::unique_lock lock(mutex_);

+        // Check size before any output without materializing the string
+        const size_t content_size = static_cast<size_t>(buffer_.tellp());
+
+        // Output to stdout (skip if too large to avoid flooding console)
</code_context>

<issue_to_address>
**issue (bug_risk):** Guard against `tellp()` failure before casting to `size_t` for size checks.

`buffer_.tellp()` can return `pos_type(-1)` on failure, which becomes a huge `size_t` and will always trip the "too large" check with an incorrect byte count. Consider capturing the result first and handling errors before casting, e.g.:

```cpp
auto pos = buffer_.tellp();
if (pos < 0) {
    // handle failure: skip size check, use content.size(), or treat as error
}
size_t content_size = static_cast<size_t>(pos);
```

At minimum, treat negative positions as an explicit error case instead of casting directly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Member Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并且给出了一些整体性的反馈:

  • LogStream 中硬编码的日志大小限制(kMaxLogSize、kTruncatedSize)让行为不够灵活;可以考虑把这些限制接到配置上,或者做成可注入的,这样不同环境就能在不重新编译的情况下调整限制。
  • 在写入之前验证文件流时,只检查 stream_.good() 可能会遗漏文件根本没有打开的情况;可以考虑显式检查 stream_.is_open()(或等价方法),并在输出到 stderr 的诊断信息中区分“未打开”和“一般错误”。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- LogStream 中硬编码的日志大小限制(kMaxLogSize、kTruncatedSize)让行为不够灵活;可以考虑把这些限制接到配置上,或者做成可注入的,这样不同环境就能在不重新编译的情况下调整限制。
- 在写入之前验证文件流时,只检查 stream_.good() 可能会遗漏文件根本没有打开的情况;可以考虑显式检查 stream_.is_open()(或等价方法),并在输出到 stderr 的诊断信息中区分“未打开”和“一般错误”。

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:78-83` </location>
<code_context>

+        // Check size before any output without materializing the string
+        // Guard against tellp() failure (returns -1 on error)
+        auto pos = buffer_.tellp();
+        size_t content_size = 0;
+        if (pos >= 0) {
+            content_size = static_cast<size_t>(pos);
+        }
+        // If tellp() failed, content_size remains 0 and won't trigger size limit
+
+        // Output to stdout (skip if too large to avoid flooding console)
</code_context>

<issue_to_address>
**issue (bug_risk):**`tellp()` 失败时,建议使用一个回退路径,而不是静默地关闭对 stdout 的大小限制。

如果 `tellp()` 失败,`content_size` 会保持为 0,因此大小保护永远不会触发,并且会抑制超大日志的警告,但此时仍然会调用 `stdout_string()`,可能会实化一个非常大的字符串。请为这种情况增加一个回退逻辑(例如,当 `pos < 0` 时使用 `buffer_.str().size()`,或者至少向 `stderr` 打一条诊断日志),这样可以避免在 `tellp()` 失败时静默绕过保护机制。
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的代码审查有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会利用这些反馈来改进对你代码的审查。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • The hard-coded log size limits (kMaxLogSize, kTruncatedSize) inside LogStream make behavior inflexible; consider wiring them to configuration or making them injectable so different environments can tune limits without recompiling.
  • When validating the file stream before writing, checking only stream_.good() may miss cases where the file is simply not open; consider explicitly checking stream_.is_open() (or equivalent) and distinguishing between 'not open' and 'error' in the diagnostic message to stderr.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The hard-coded log size limits (kMaxLogSize, kTruncatedSize) inside LogStream make behavior inflexible; consider wiring them to configuration or making them injectable so different environments can tune limits without recompiling.
- When validating the file stream before writing, checking only stream_.good() may miss cases where the file is simply not open; consider explicitly checking stream_.is_open() (or equivalent) and distinguishing between 'not open' and 'error' in the diagnostic message to stderr.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:78-83` </location>
<code_context>

+        // Check size before any output without materializing the string
+        // Guard against tellp() failure (returns -1 on error)
+        auto pos = buffer_.tellp();
+        size_t content_size = 0;
+        if (pos >= 0) {
+            content_size = static_cast<size_t>(pos);
+        }
+        // If tellp() failed, content_size remains 0 and won't trigger size limit
+
+        // Output to stdout (skip if too large to avoid flooding console)
</code_context>

<issue_to_address>
**issue (bug_risk):** Consider a fallback path when `tellp()` fails instead of silently disabling the stdout size limit.

If `tellp()` fails, `content_size` remains 0, so the size guard never triggers and the oversized-log warning is suppressed, yet `stdout_string()` is still called and may materialize a very large string. Please add a fallback for this case (e.g., use `buffer_.str().size()` when `pos < 0`, or at least log a diagnostic to `stderr`) so `tellp()` failures don’t silently bypass the protection.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Member Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些总体反馈:

  • LogStream::operator<< 中,你多次调用 buffer_.str()(一次在 tellp() 回退分支,一次在生成 content 时);建议将该字符串缓存到一个局部变量中,这样大小检查和截断可以复用同一次物化结果,同时避免额外拷贝。
  • 新增的大小常量 kMaxLogSizekTruncatedSize 隐含假设 kTruncatedSize <= kMaxLogSize;为了避免将来修改时不小心颠倒这一关系,最好通过 static_assert 显式约束这一条件。
  • 日志路径中新加的 stderr 警告/错误(例如针对过大日志项、tellp() 失败以及非法流)在某些环境下可能会非常嘈杂;可以考虑通过调试标志或日志级别检查来进行控制,避免在生产环境中向 stderr 打印过多信息。
面向 AI Agents 的提示
Please address the comments from this code review:

## Overall Comments
- In `LogStream::operator<<`, you call `buffer_.str()` multiple times (once in the `tellp()` fallback and again when materializing `content`); consider caching the string in a local variable so size checks and truncation reuse the same materialization and avoid extra copies.
- The new size constants `kMaxLogSize` and `kTruncatedSize` assume `kTruncatedSize <= kMaxLogSize`; it might be safer to enforce this via a `static_assert` so future changes don't accidentally invert the relationship.
- The new stderr warnings/errors in the log path (e.g., for oversized entries, `tellp()` failure, and invalid streams) may be quite noisy in some environments; consider gating them behind a debug flag or log-level check to reduce potential stderr flooding in production.

## Individual Comments

### Comment 1
<location> `source/Logger/Logger.cpp:164-168` </location>
<code_context>
     // https://stackoverflow.com/questions/55513974/controlling-inheritability-of-file-handles-created-by-c-stdfstream-in-window
     std::string str_log_path = log_path_.string();
     FILE* file_ptr = fopen(str_log_path.c_str(), append ? "a" : "w");
+    if (!file_ptr) {
+        // Failed to open file, log to stderr and explicitly reset stream
+        std::cerr << "Failed to open log file: " << str_log_path << std::endl;
+        ofs_ = std::ofstream(); // Reset to default-constructed (closed) state
+        return;
+    }
     SetHandleInformation((HANDLE)_get_osfhandle(_fileno(file_ptr)), HANDLE_FLAG_INHERIT, 0);
</code_context>

<issue_to_address>
**suggestion:** Include more detail in the log message on `fopen` failure to aid diagnosis.

Currently only the path is logged, which doesn’t explain *why* `fopen` failed. Please include the error string as well (e.g. via `std::strerror(errno)` or equivalent) so callers can distinguish between causes like permission denied, missing directory, etc.

Suggested implementation:

```cpp
    FILE* file_ptr = fopen(str_log_path.c_str(), append ? "a" : "w");
    if (!file_ptr) {
        // Failed to open file, log to stderr and explicitly reset stream
        std::cerr << "Failed to open log file: " << str_log_path
                  << " (errno=" << errno << ", " << std::strerror(errno) << ')'
                  << std::endl;
        ofs_ = std::ofstream(); // Reset to default-constructed (closed) state
        return;
    }

```

To compile successfully, ensure that at the top of `source/Logger/Logger.cpp` you include the necessary headers for `errno` and `std::strerror`:

- Add `#include <cerrno>` (for `errno`)
- Add `#include <cstring>` (for `std::strerror`)

If these headers are already present, no further changes are required.
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点亮 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In LogStream::operator<<, you call buffer_.str() multiple times (once in the tellp() fallback and again when materializing content); consider caching the string in a local variable so size checks and truncation reuse the same materialization and avoid extra copies.
  • The new size constants kMaxLogSize and kTruncatedSize assume kTruncatedSize <= kMaxLogSize; it might be safer to enforce this via a static_assert so future changes don't accidentally invert the relationship.
  • The new stderr warnings/errors in the log path (e.g., for oversized entries, tellp() failure, and invalid streams) may be quite noisy in some environments; consider gating them behind a debug flag or log-level check to reduce potential stderr flooding in production.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `LogStream::operator<<`, you call `buffer_.str()` multiple times (once in the `tellp()` fallback and again when materializing `content`); consider caching the string in a local variable so size checks and truncation reuse the same materialization and avoid extra copies.
- The new size constants `kMaxLogSize` and `kTruncatedSize` assume `kTruncatedSize <= kMaxLogSize`; it might be safer to enforce this via a `static_assert` so future changes don't accidentally invert the relationship.
- The new stderr warnings/errors in the log path (e.g., for oversized entries, `tellp()` failure, and invalid streams) may be quite noisy in some environments; consider gating them behind a debug flag or log-level check to reduce potential stderr flooding in production.

## Individual Comments

### Comment 1
<location> `source/Logger/Logger.cpp:164-168` </location>
<code_context>
     // https://stackoverflow.com/questions/55513974/controlling-inheritability-of-file-handles-created-by-c-stdfstream-in-window
     std::string str_log_path = log_path_.string();
     FILE* file_ptr = fopen(str_log_path.c_str(), append ? "a" : "w");
+    if (!file_ptr) {
+        // Failed to open file, log to stderr and explicitly reset stream
+        std::cerr << "Failed to open log file: " << str_log_path << std::endl;
+        ofs_ = std::ofstream(); // Reset to default-constructed (closed) state
+        return;
+    }
     SetHandleInformation((HANDLE)_get_osfhandle(_fileno(file_ptr)), HANDLE_FLAG_INHERIT, 0);
</code_context>

<issue_to_address>
**suggestion:** Include more detail in the log message on `fopen` failure to aid diagnosis.

Currently only the path is logged, which doesn’t explain *why* `fopen` failed. Please include the error string as well (e.g. via `std::strerror(errno)` or equivalent) so callers can distinguish between causes like permission denied, missing directory, etc.

Suggested implementation:

```cpp
    FILE* file_ptr = fopen(str_log_path.c_str(), append ? "a" : "w");
    if (!file_ptr) {
        // Failed to open file, log to stderr and explicitly reset stream
        std::cerr << "Failed to open log file: " << str_log_path
                  << " (errno=" << errno << ", " << std::strerror(errno) << ')'
                  << std::endl;
        ofs_ = std::ofstream(); // Reset to default-constructed (closed) state
        return;
    }

```

To compile successfully, ensure that at the top of `source/Logger/Logger.cpp` you include the necessary headers for `errno` and `std::strerror`:

- Add `#include <cerrno>` (for `errno`)
- Add `#include <cstring>` (for `std::strerror`)

If these headers are already present, no further changes are required.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@SourceryAI SourceryAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些高层次的反馈:

  • LogStream::operator<</flush 中,你在 tellp() 失败的回退路径和后面构造 content 时都调用了一次 buffer_.str();可以考虑至多只将字符串物化一次(然后复用它),以避免额外的内存分配,并让尺寸检查与实际写入的内容保持一致。
  • stream_ 没有打开或处于错误状态时,你目前只是向 stderr 记录一条错误日志并丢弃该条日志记录;可以考虑在这些路径中也把(可能被截断的)日志内容输出到 stderr,避免重要日志被静默丢失。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- In `LogStream::operator<<`/flush, you call `buffer_.str()` both in the `tellp()`-failure fallback and again later to build `content`; consider materializing the string at most once (and reusing it) to avoid extra allocation and keep the size check consistent with what is actually written.
- When `stream_` is not open or in an error state you currently just log an error to `stderr` and drop the entry; consider also emitting the (possibly truncated) log content to `stderr` in these paths so that important messages are not silently lost.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:78-87` </location>
<code_context>
+        auto pos = buffer_.tellp();
</code_context>

<issue_to_address>
**suggestion (performance):** Avoid recomputing `buffer_.str()` on the fallback path to reduce overhead for oversized logs.

On the `tellp()` failure path, `buffer_.str()` is invoked once to compute `content_size` and again to initialize `content`. For very large log entries, this double materialization is costly. Instead, compute it once in the fallback branch (e.g., `auto serialized = buffer_.str();`), use `serialized.size()` for the check, and then move `serialized` into `content` to avoid the second call.

Suggested implementation:

```c
        // Check size before any output without materializing the string
        // Guard against tellp() failure (returns -1 on error)
        auto pos = buffer_.tellp();
        std::string serialized;  // may hold materialized content in fallback path
        size_t content_size = 0;
        if (pos >= 0) {
            content_size = static_cast<size_t>(pos);
        } else {
            // Fallback: materialize string once to get size if tellp() fails
            serialized = buffer_.str();
            content_size = serialized.size();
            std::cerr << "[WARNING: tellp() failed, using fallback size check]" << std::endl;
        }

        // Output to stdout (skip if too large to avoid flooding console)

```

To fully leverage the single materialization and avoid a second `buffer_.str()` call later in this function:

1. When you construct the final `content` string (or equivalent), use:
   - `std::string content = serialized.empty() ? buffer_.str() : std::move(serialized);`
2. Ensure this construction happens in the same scope so it can access the `serialized` variable introduced above.
This will eliminate the extra `buffer_.str()` call on the `tellp()` failure path while preserving behavior on the success path.
</issue_to_address>

Hi @Windsland52! 👋

感谢你通过评论 @sourcery-ai review 来体验 Sourcery!🚀

安装 sourcery-ai 机器人,即可在每个 Pull Request 上自动获得代码审查 ✨

帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的审查。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In LogStream::operator<</flush, you call buffer_.str() both in the tellp()-failure fallback and again later to build content; consider materializing the string at most once (and reusing it) to avoid extra allocation and keep the size check consistent with what is actually written.
  • When stream_ is not open or in an error state you currently just log an error to stderr and drop the entry; consider also emitting the (possibly truncated) log content to stderr in these paths so that important messages are not silently lost.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `LogStream::operator<<`/flush, you call `buffer_.str()` both in the `tellp()`-failure fallback and again later to build `content`; consider materializing the string at most once (and reusing it) to avoid extra allocation and keep the size check consistent with what is actually written.
- When `stream_` is not open or in an error state you currently just log an error to `stderr` and drop the entry; consider also emitting the (possibly truncated) log content to `stderr` in these paths so that important messages are not silently lost.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:78-87` </location>
<code_context>
+        auto pos = buffer_.tellp();
</code_context>

<issue_to_address>
**suggestion (performance):** Avoid recomputing `buffer_.str()` on the fallback path to reduce overhead for oversized logs.

On the `tellp()` failure path, `buffer_.str()` is invoked once to compute `content_size` and again to initialize `content`. For very large log entries, this double materialization is costly. Instead, compute it once in the fallback branch (e.g., `auto serialized = buffer_.str();`), use `serialized.size()` for the check, and then move `serialized` into `content` to avoid the second call.

Suggested implementation:

```c
        // Check size before any output without materializing the string
        // Guard against tellp() failure (returns -1 on error)
        auto pos = buffer_.tellp();
        std::string serialized;  // may hold materialized content in fallback path
        size_t content_size = 0;
        if (pos >= 0) {
            content_size = static_cast<size_t>(pos);
        } else {
            // Fallback: materialize string once to get size if tellp() fails
            serialized = buffer_.str();
            content_size = serialized.size();
            std::cerr << "[WARNING: tellp() failed, using fallback size check]" << std::endl;
        }

        // Output to stdout (skip if too large to avoid flooding console)

```

To fully leverage the single materialization and avoid a second `buffer_.str()` call later in this function:

1. When you construct the final `content` string (or equivalent), use:
   - `std::string content = serialized.empty() ? buffer_.str() : std::move(serialized);`
2. Ensure this construction happens in the same scope so it can access the `serialized` variable introduced above.
This will eliminate the extra `buffer_.str()` call on the `tellp()` failure path while preserving behavior on the success path.
</issue_to_address>

Hi @Windsland52! 👋

Thanks for trying out Sourcery by commenting with @sourcery-ai review! 🚀

Install the sourcery-ai bot to get automatic code reviews on every pull request ✨

Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Member Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些总体反馈:

  • LogStream::flush() 中,之前使用 std::move(buffer_).str() 会隐式清空缓冲区;在新的实现中使用的是 buffer_.str() 且没有重置缓冲区,这样后续的日志条目可能会反复包含旧内容——建议在写出之后显式清空/重置 buffer_
  • 截断逻辑中使用 std::format 会引入 C++20 依赖,从而降低可移植性;如果项目需要支持更老的工具链或嵌入式环境,建议改用 fmtlib,或采用更简单的手动格式化方式。
  • Logger::open() 中调用的 strerror() 在某些平台上不是线程安全的;为避免在多线程日志场景下出现潜在的数据竞争,建议改用 strerror_s / strerror_r,或 std::system_category().message(errno)
供 AI 代理使用的提示
Please address the comments from this code review:

## Overall Comments
- In LogStream::flush(), the previous use of std::move(buffer_).str() implicitly cleared the buffer; with the new implementation using buffer_.str() and not resetting the buffer, subsequent log entries may repeatedly include old content—consider explicitly clearing/resetting buffer_ after writing.
- The use of std::format in the truncation path introduces a C++20 dependency and may reduce portability; if the project targets older toolchains or embedded environments, consider replacing it with fmtlib or a simpler manual formatting approach.
- The strerror() call in Logger::open() is not thread-safe on some platforms; to avoid potential data races in multi-threaded logging, consider using strerror_s/strerror_r or std::system_category().message(errno) instead.

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • In LogStream::flush(), the previous use of std::move(buffer_).str() implicitly cleared the buffer; with the new implementation using buffer_.str() and not resetting the buffer, subsequent log entries may repeatedly include old content—consider explicitly clearing/resetting buffer_ after writing.
  • The use of std::format in the truncation path introduces a C++20 dependency and may reduce portability; if the project targets older toolchains or embedded environments, consider replacing it with fmtlib or a simpler manual formatting approach.
  • The strerror() call in Logger::open() is not thread-safe on some platforms; to avoid potential data races in multi-threaded logging, consider using strerror_s/strerror_r or std::system_category().message(errno) instead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In LogStream::flush(), the previous use of std::move(buffer_).str() implicitly cleared the buffer; with the new implementation using buffer_.str() and not resetting the buffer, subsequent log entries may repeatedly include old content—consider explicitly clearing/resetting buffer_ after writing.
- The use of std::format in the truncation path introduces a C++20 dependency and may reduce portability; if the project targets older toolchains or embedded environments, consider replacing it with fmtlib or a simpler manual formatting approach.
- The strerror() call in Logger::open() is not thread-safe on some platforms; to avoid potential data races in multi-threaded logging, consider using strerror_s/strerror_r or std::system_category().message(errno) instead.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Member Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗨——我发现了 1 个问题,并给出了一些整体反馈:

  • LogStream::flush() 中,正常路径里你仍然对缓冲区做了两次实体化(stdout_string() 然后 buffer_.str());可以考虑复用同一个缓存好的字符串用于 stdout 和文件输出,以避免重复的内存分配和字符串构造。
  • 在截断的热点路径中使用 std::format 可能相对较重,而且现在是用一个兜底的 catch-all 来保护;如果你关心性能或对非 C++20 工具链的可移植性,建议用更简单的格式化方式替代(例如字符串拼接或 fmtlib)。
  • 固定大小限制 kMaxLogSizekTruncatedSize 是硬编码在 LogStream 里的;如果不同部署可能需要不同阈值,建议把它们做成可配置参数(例如通过 Logger 或配置结构体传入),而不是编译期常量。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- In LogStream::flush(), you still materialize the buffer twice in the normal path (stdout_string() and then buffer_.str()); consider reusing the same cached string for stdout and file output to avoid duplicate allocations and string construction.
- The use of std::format inside the hot path for truncation can be relatively heavy and is guarded by a catch-all; if performance or portability to non-C++20 toolchains is a concern, consider replacing it with a simpler formatting approach (e.g., string concatenation or fmtlib).
- The hardcoded size limits kMaxLogSize and kTruncatedSize are embedded in LogStream; if different deployments may need different thresholds, consider plumbing these as configurable parameters (e.g., via Logger or a config struct) rather than compile-time constants.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:101-110` </location>
<code_context>
+        // Get content (reuse cached if available, otherwise materialize now)
</code_context>

<issue_to_address>
**issue (bug_risk):** Log buffer is no longer cleared after flush, so content will accumulate across log entries.

With `std::move(buffer_).str()` removed, we now only call `buffer_.str()` and never reset the stream or its state. Subsequent `flush()` calls will re-log old content and grow the buffer indefinitely. Please clear and reset the buffer at the end of `flush()` (e.g. `buffer_.str({}); buffer_.clear();`).
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的代码评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In LogStream::flush(), you still materialize the buffer twice in the normal path (stdout_string() and then buffer_.str()); consider reusing the same cached string for stdout and file output to avoid duplicate allocations and string construction.
  • The use of std::format inside the hot path for truncation can be relatively heavy and is guarded by a catch-all; if performance or portability to non-C++20 toolchains is a concern, consider replacing it with a simpler formatting approach (e.g., string concatenation or fmtlib).
  • The hardcoded size limits kMaxLogSize and kTruncatedSize are embedded in LogStream; if different deployments may need different thresholds, consider plumbing these as configurable parameters (e.g., via Logger or a config struct) rather than compile-time constants.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In LogStream::flush(), you still materialize the buffer twice in the normal path (stdout_string() and then buffer_.str()); consider reusing the same cached string for stdout and file output to avoid duplicate allocations and string construction.
- The use of std::format inside the hot path for truncation can be relatively heavy and is guarded by a catch-all; if performance or portability to non-C++20 toolchains is a concern, consider replacing it with a simpler formatting approach (e.g., string concatenation or fmtlib).
- The hardcoded size limits kMaxLogSize and kTruncatedSize are embedded in LogStream; if different deployments may need different thresholds, consider plumbing these as configurable parameters (e.g., via Logger or a config struct) rather than compile-time constants.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:101-110` </location>
<code_context>
+        // Get content (reuse cached if available, otherwise materialize now)
</code_context>

<issue_to_address>
**issue (bug_risk):** Log buffer is no longer cleared after flush, so content will accumulate across log entries.

With `std::move(buffer_).str()` removed, we now only call `buffer_.str()` and never reset the stream or its state. Subsequent `flush()` calls will re-log old content and grow the buffer indefinitely. Please clear and reset the buffer at the end of `flush()` (e.g. `buffer_.str({}); buffer_.clear();`).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Member Author

@sourcery-ai review

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些整体层面的反馈:

  • LogStream 中,构造函数的默认参数在这些成员声明之前就引用了 kDefaultMaxLogSizekDefaultTruncatedSize,这在某些编译器上可能无法通过编译;建议将这些 static constexpr 声明移动到构造函数之前,或者使用单独的、用于默认值的类内 constexpr 帮助变量。
  • 当调用方提供自定义的 max_log_sizetruncated_size 时,并不像默认值那样保证 truncated_size <= max_log_size;建议在构造函数中对这一关系进行限制(clamp)或断言,以避免意外的截断行为。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `LogStream`, the constructor’s default arguments reference `kDefaultMaxLogSize` and `kDefaultTruncatedSize` before those members are declared, which may not compile on all compilers; consider moving the static constexpr declarations above the constructor or using a separate constexpr in-class helper for the defaults.
- When callers provide custom `max_log_size` and `truncated_size`, there is no guarantee that `truncated_size <= max_log_size` as there is for the defaults; consider clamping or asserting this relationship in the constructor to avoid surprising truncation behavior.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:60-68` </location>
<code_context>
 public:
     template <typename... args_t>
-    LogStream(std::mutex& m, std::ofstream& s, level lv, bool std_out, args_t&&... args)
+    LogStream(std::mutex& m, std::ofstream& s, level lv, bool std_out,
+              size_t max_log_size = kDefaultMaxLogSize,
+              size_t truncated_size = kDefaultTruncatedSize,
+              args_t&&... args)
         : mutex_(m)
         , stream_(s)
         , lv_(lv)
         , stdout_(std_out)
+        , max_log_size_(max_log_size)
+        , truncated_size_(truncated_size)
     {
</code_context>

<issue_to_address>
**issue (bug_risk):** Referencing kDefaultMaxLogSize/kDefaultTruncatedSize in default parameters may be ill-formed if those members are not visible yet.

These default arguments refer to kDefaultMaxLogSize and kDefaultTruncatedSize, which are declared later in the class. Since default argument lookup may not see members declared afterwards, this can be ill-formed on some compilers/standards. Please either declare the static constexpr members before the constructor, or move the constructor definition out of the class and specify the defaults after those members are declared.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In LogStream, the constructor’s default arguments reference kDefaultMaxLogSize and kDefaultTruncatedSize before those members are declared, which may not compile on all compilers; consider moving the static constexpr declarations above the constructor or using a separate constexpr in-class helper for the defaults.
  • When callers provide custom max_log_size and truncated_size, there is no guarantee that truncated_size <= max_log_size as there is for the defaults; consider clamping or asserting this relationship in the constructor to avoid surprising truncation behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `LogStream`, the constructor’s default arguments reference `kDefaultMaxLogSize` and `kDefaultTruncatedSize` before those members are declared, which may not compile on all compilers; consider moving the static constexpr declarations above the constructor or using a separate constexpr in-class helper for the defaults.
- When callers provide custom `max_log_size` and `truncated_size`, there is no guarantee that `truncated_size <= max_log_size` as there is for the defaults; consider clamping or asserting this relationship in the constructor to avoid surprising truncation behavior.

## Individual Comments

### Comment 1
<location> `include/MaaUtils/LoggerUtils.h:60-68` </location>
<code_context>
 public:
     template <typename... args_t>
-    LogStream(std::mutex& m, std::ofstream& s, level lv, bool std_out, args_t&&... args)
+    LogStream(std::mutex& m, std::ofstream& s, level lv, bool std_out,
+              size_t max_log_size = kDefaultMaxLogSize,
+              size_t truncated_size = kDefaultTruncatedSize,
+              args_t&&... args)
         : mutex_(m)
         , stream_(s)
         , lv_(lv)
         , stdout_(std_out)
+        , max_log_size_(max_log_size)
+        , truncated_size_(truncated_size)
     {
</code_context>

<issue_to_address>
**issue (bug_risk):** Referencing kDefaultMaxLogSize/kDefaultTruncatedSize in default parameters may be ill-formed if those members are not visible yet.

These default arguments refer to kDefaultMaxLogSize and kDefaultTruncatedSize, which are declared later in the class. Since default argument lookup may not see members declared afterwards, this can be ill-formed on some compilers/standards. Please either declare the static constexpr members before the constructor, or move the constructor definition out of the class and specify the defaults after those members are declared.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +60 to +68
LogStream(std::mutex& m, std::ofstream& s, level lv, bool std_out,
size_t max_log_size = kDefaultMaxLogSize,
size_t truncated_size = kDefaultTruncatedSize,
args_t&&... args)
: mutex_(m)
, stream_(s)
, lv_(lv)
, stdout_(std_out)
, max_log_size_(max_log_size)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): 在默认参数中引用 kDefaultMaxLogSize/kDefaultTruncatedSize 时,如果这些成员尚未可见,可能会导致格式不合法(ill-formed)。

这些默认参数引用了在类中稍后声明的 kDefaultMaxLogSize 和 kDefaultTruncatedSize。由于默认参数查找可能无法看到之后才声明的成员,这在某些编译器或标准下会是 ill-formed。请将这些 static constexpr 成员声明移动到构造函数之前,或者将构造函数定义移出类体,并在这些成员声明之后再为其指定默认参数。

Original comment in English

issue (bug_risk): Referencing kDefaultMaxLogSize/kDefaultTruncatedSize in default parameters may be ill-formed if those members are not visible yet.

These default arguments refer to kDefaultMaxLogSize and kDefaultTruncatedSize, which are declared later in the class. Since default argument lookup may not see members declared afterwards, this can be ill-formed on some compilers/standards. Please either declare the static constexpr members before the constructor, or move the constructor definition out of the class and specify the defaults after those members are declared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants