Skip to content

[ENG-6830] add timestamps to debug logs#5618

Merged
adhami3310 merged 1 commit into
mainfrom
masenf/debug-log-timestamp
Jul 22, 2025
Merged

[ENG-6830] add timestamps to debug logs#5618
adhami3310 merged 1 commit into
mainfrom
masenf/debug-log-timestamp

Conversation

@masenf
Copy link
Copy Markdown
Collaborator

@masenf masenf commented Jul 22, 2025

No description provided.

@linear
Copy link
Copy Markdown

linear Bot commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR adds timestamps to debug logs by modifying the print_to_log_file function in reflex/utils/console.py. The change imports the datetime module and prepends a timestamp in square brackets to all log file messages using datetime.datetime.now().

The modification only affects file-based logging - messages written to log files now include timestamps, while console output remains unchanged. This enhancement improves debugging capabilities by providing temporal context for log entries, which is particularly valuable for troubleshooting long-running processes or analyzing system behavior over time.

The change integrates well with the existing logging infrastructure in Reflex, which already separates console display from file logging functionality. The print_to_log_file function is used throughout the codebase by various logging methods (debug, info, warn, error, etc.) when file logging is enabled, so this single change adds timestamps to all file-based log messages uniformly.

Confidence score: 3/5

  • This PR is generally safe to merge but has some considerations around timestamp format and timezone handling
  • The score reflects potential issues with timestamp format (no timezone info) and lack of configurability, though the core functionality is sound
  • The print_to_log_file function in reflex/utils/console.py needs attention for timestamp format considerations

1 file reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

Comment thread reflex/utils/console.py
kwargs: Keyword arguments to pass to the print function.
"""
log_file_console().print(msg, **kwargs)
log_file_console().print(f"[{datetime.datetime.now()}] {msg}", **kwargs)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: Consider using a more consistent timestamp format like ISO 8601 or match the existing timestamp format used in log_file_console() (lines 108-109) for consistency

Comment thread reflex/utils/console.py
kwargs: Keyword arguments to pass to the print function.
"""
log_file_console().print(msg, **kwargs)
log_file_console().print(f"[{datetime.datetime.now()}] {msg}", **kwargs)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: datetime.datetime.now() uses local timezone. Consider using datetime.datetime.now(datetime.timezone.utc) for UTC timestamps to avoid timezone ambiguity in logs

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jul 22, 2025

CodSpeed Performance Report

Merging #5618 will not alter performance

Comparing masenf/debug-log-timestamp (00a989f) with main (0c40fdd)

Summary

✅ 8 untouched benchmarks

@adhami3310 adhami3310 merged commit b052299 into main Jul 22, 2025
39 of 41 checks passed
@adhami3310 adhami3310 deleted the masenf/debug-log-timestamp branch July 22, 2025 23:14
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.

2 participants