Add context to logger to pass external log line marker for rclone and rclone rcd by sam-mt · Pull Request #9311 · rclone/rclone
What is the purpose of this change?
I need to add more info to rclone and rclone rcd logs, so I can separate output from different jobs or rclone instances in the log stream.
This MR is purpose is rather to discuss if this change is acceptable at all or maybe there is a different solution to this.
My changes adds a context-propagating log-tag system that lets every log line emitted inside an RC job carry a short identifying prefix and flag that can be set in command line.
RC:
_logtag: absent - tag defaults to the job's _group name
_logtag: "" - tagging disabled entirely
_logtag: "my_tag" - custom tag applied
The _logtag RC parameter follows the existing _config/_filter/_group pattern, and the tag is rendered in both text (prefix) and JSON ("log_tag" field) formats.
Rclone:
--log-prefix="rclone-1" will produce:
2026/04/03 17:54:33 rclone-1 DEBUG : Added delayed dir = "test_UuswduZmsOzRZRq", newDst=<nil>
2026/04/03 17:54:33 rclone-1 DEBUG : Added delayed dir = "test_zooLrewymKzTmtpeTig", newDst=<nil>
2026/04/03 17:54:33 rclone-1 INFO : test1: Set directory modification time (using SetModTime)
Most the changes are here:
fs/log.go
fs/log/slog.go
Was the change discussed in an issue or in the forum before?
I think I saw some discussions but was not able to find them
Checklist
- I have read the contribution guidelines.
- I have added tests for all changes in this PR if appropriate.
- I have added documentation for the changes if appropriate.
- All commit messages are in house style.
- I'm done, this Pull Request is ready for review :-)