Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 18, 2025

Setup server logging to file using standard XDG dir

  • Add directories dependency to djls-server crate
  • Update init_tracing function to use XDG cache directory instead of /tmp
  • Update documentation comments to reflect new log location
  • Add tests for XDG directory logic
  • Test the changes manually
  • Run existing tests to ensure no regressions
  • Refactor log directory logic to djls-conf crate
  • Change log_dir to const and use Camino Utf8 paths
  • Move all log directory logic including creation to djls-conf function
  • Replace unwrap with graceful fallback for UTF-8 conversion
Original prompt

This section details on the original issue you should resolve

<issue_title>Setup server logging to file using standard XDG dir</issue_title>
<issue_description>Follow up to #170, right now we're just logging to /tmp but we should really use the XDG standard dir for this -- especially because we have the directories crate right there.</issue_description>

<agent_instructions>We already have the pieces for this in place, directories crate for XDG dirs, logging infrastructure, they just need to be plugged together</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #180


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

- Added directories dependency to djls-server
- Updated init_tracing to use XDG cache dir with /tmp fallback
- Added tests to verify log directory logic
- Updated documentation to reflect new log location

Co-authored-by: joshuadavidthomas <[email protected]>
Copilot AI changed the title [WIP] Setup server logging to file using XDG standard directory Setup server logging to file using standard XDG directory Oct 18, 2025
Copilot finished work on behalf of joshuadavidthomas October 18, 2025 15:54
@joshuadavidthomas
Copy link
Owner

@copilot logic for the location of the logging dir should be in the conf crate and exported from it and used in the server crate.

- Added log_dir() function to djls-conf that returns XDG cache directory
- Updated djls-server to use djls_conf::log_dir() instead of local logic
- Removed directories dependency from djls-server
- Moved log directory tests to djls-conf where the logic lives

Co-authored-by: joshuadavidthomas <[email protected]>
Copy link
Contributor Author

Copilot AI commented Oct 18, 2025

@copilot logic for the location of the logging dir should be in the conf crate and exported from it and used in the server crate.

Done. Added log_dir() function to djls-conf that returns the XDG cache directory, and updated djls-server to use it. The directories dependency has been removed from djls-server since it now uses the exported function. (commit: see above)

Copilot finished work on behalf of joshuadavidthomas October 18, 2025 16:15
- Changed log_dir() function to LOG_DIR static with LazyLock
- Updated to use Camino Utf8PathBuf instead of std::path::PathBuf
- Updated djls-server to dereference the static constant
- Updated tests to work with the new static constant

Co-authored-by: joshuadavidthomas <[email protected]>
Copilot finished work on behalf of joshuadavidthomas October 18, 2025 16:30
- Changed LOG_DIR static back to log_dir() function returning Result
- Moved directory creation logic from djls-server to djls-conf
- Updated init_tracing to return Result and use log_dir()?
- Added proper error handling with anyhow::Context
- Added comprehensive documentation with Errors and Panics sections
- Added test to verify directory creation

Co-authored-by: joshuadavidthomas <[email protected]>
Copilot finished work on behalf of joshuadavidthomas October 18, 2025 16:51
- Changed from .unwrap() to .ok() for Utf8PathBuf conversion
- Now falls back to /tmp if XDG cache path contains invalid UTF-8
- Removed Panics documentation section as function no longer panics

Co-authored-by: joshuadavidthomas <[email protected]>
Copilot finished work on behalf of joshuadavidthomas October 18, 2025 17:06
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 18, 2025

CodSpeed Performance Report

Merging #334 will not alter performance

Comparing copilot/setup-server-logging-to-xdg-dir (25dc20f) with main (832a588)1

Summary

✅ 20 untouched

Footnotes

  1. No successful run was found on main (b951058) during the generation of this report, so 832a588 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@joshuadavidthomas joshuadavidthomas marked this pull request as ready for review October 18, 2025 19:11
@joshuadavidthomas joshuadavidthomas merged commit 0010a71 into main Oct 18, 2025
33 checks passed
@joshuadavidthomas joshuadavidthomas deleted the copilot/setup-server-logging-to-xdg-dir branch October 18, 2025 19:17
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.

Setup server logging to file using standard XDG dir

2 participants