Skip to content

Timestamp InfraScan CLI logs to show scan duration distribution#72

Open
Natan-gal wants to merge 3 commits into
SolDevelo:mainfrom
Natan-gal:patch-5
Open

Timestamp InfraScan CLI logs to show scan duration distribution#72
Natan-gal wants to merge 3 commits into
SolDevelo:mainfrom
Natan-gal:patch-5

Conversation

@Natan-gal
Copy link
Copy Markdown
Contributor

Summary

Added timestamped log messages to the InfraScan CLI to make it easier to see how long each major stage of the scan takes.

Changes

Added a log_with_timestamp() helper that prefixes messages with the current timestamp in the format:

[YYYY-MM-DD HH:MM:SS] Message

Added timestamped logs for the following stages:

  • Starting analysis
  • Starting directory scan
  • Directory scan completed
  • Generating report
  • Report generation completed
  • Saving report to file
  • Sending Slack notification
  • Evaluating fail conditions
  • Successful completion
  • Error handling

Purpose

InfraScan builds can take more than 20 minutes to complete. These timestamps make it possible to identify which parts of the process consume the most time.

Notes

External tool output (e.g. Docker Scout, Grype) is not modified, but the added timestamped logs provide clear boundaries around the major processing steps.

Added a logging function to print messages with timestamps, enhancing the visibility of the scanning process. Updated the main function to utilize this logging for various stages of execution.
Comment thread cli.py Outdated
from datetime import datetime


def log_with_timestamp(message: str) -> None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Move this lower, so that it is next to other method definitions

Comment thread cli.py Outdated
[2026-10-10 16:23:34] Starting scan...
"""
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(f"[{timestamp}] {message}", flush=True)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we use logging for this? We configure logging below

Comment thread cli.py
traceback.print_exc()
sys.exit(1)

if __name__ == "__main__":
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is why this doesn't run, you removed the main check

Natan-gal added 2 commits May 19, 2026 15:21
Updated logging configuration to use INFO level and added timestamps to log messages. Replaced print statements with logger calls for error handling and notifications.
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