alan-turing-institute / data-safe-haven

https://data-safe-haven.readthedocs.io
BSD 3-Clause "New" or "Revised" License
50 stars 14 forks source link

Logging #1936

Closed JimMadge closed 1 week ago

JimMadge commented 1 week ago

:white_check_mark: Checklist

:vertical_traffic_light: Depends on

:arrow_heading_up: Summary

The approach here is

with logging levels

:closed_umbrella: Related issues

Closes #1891 Closes #1657

:microscope: Tests

github-actions[bot] commented 1 week ago

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  data_safe_haven
  __init__.py
  directories.py
  data_safe_haven/administration/users
  entra_users.py 29
  user_handler.py 29, 129, 155, 161
  data_safe_haven/commands
  cli.py 57, 60, 100
  config.py
  context.py
  pulumi.py
  sre.py 32
  users.py 128, 230
  data_safe_haven/config
  config.py
  data_safe_haven/context
  context_settings.py
  data_safe_haven/exceptions
  __init__.py
  data_safe_haven/external/api
  azure_api.py 753
  azure_cli.py 75
  graph_api.py 87, 1086, 1112-1119
  data_safe_haven/external/interface
  azure_postgresql_database.py 54, 151, 159
  data_safe_haven/infrastructure
  project_manager.py 176, 251-254, 262, 272, 306
  data_safe_haven/infrastructure/components/dynamic
  entra_application.py 43, 69, 125
  ssl_certificate.py 51, 81, 156
  data_safe_haven/logging
  __init__.py
  logger.py
  data_safe_haven/provisioning
  sre_provisioning_manager.py 32, 117
  data_safe_haven/utility
  console.py 17-25
  prompts.py
Project Total  

The report is truncated to 25 files out of 31. To see the full report, please visit the workflow summary page.

This report was generated by python-coverage-comment-action

jemrobinson commented 1 week ago

Something to consider (no problem if you decide not to) - should we log all runs to $appdirs / $date-$user-something.log and potentially also upload these to Azure for future reference?

JimMadge commented 1 week ago

Merged through docs link check failing as that wasn't modified here. Does look like a genuine failure though.

JimMadge commented 6 days ago

Screenshots,

Screenshot 2024-06-20 at 11 15 26
JimMadge commented 6 days ago

And the log file,

2024-06-20 11:13:47,048 - DEBUG - Reading project settings from '/Users/jmadge/Library/Application Support/data_safe_haven/contexts.yaml'.
2024-06-20 11:13:47,067 - INFO - Switched context to 'elements'.
2024-06-20 11:13:47,073 - DEBUG - Saved context settings to '/Users/jmadge/Library/Application Support/data_safe_haven/contexts.yaml'.
2024-06-20 11:14:06,576 - DEBUG - Reading project settings from '/Users/jmadge/Library/Application Support/data_safe_haven/contexts.yaml'.
2024-06-20 11:14:06,586 - INFO - Switched context to 'elements'.
2024-06-20 11:14:06,595 - DEBUG - Saved context settings to '/Users/jmadge/Library/Application Support/data_safe_haven/contexts.yaml'.
jemrobinson commented 6 days ago

Looks great. I like the idea of keeping timestamps in the log file but not in the console output (by default). Do you think there's any benefit in adding an option to include timestamps in the console output?

JimMadge commented 6 days ago

Looks great. I like the idea of keeping timestamps in the log file but not in the console output (by default). Do you think there's any benefit in adding an option to include timestamps in the console output?

That did occur to me when I posted the pictures. Could definitely do that too, should be an easy addition.