[go: up one dir, main page]

Skip to content

Log message if file in local directory disappears or otherwise cannot be read

When working with a local content source (i.e., worktree) or UI bundle directory, it's likely that Antora will come across a file when scanning which has disappeared or which otherwise cannot be read. The former can happen if there's another process running that's reading and writing files to the directory, such as an IDE or file watcher. The files are also changing from run to run as the author works on the source. Since these are all common scenarios in the author's workflow, the file scanner should be more graceful by logging a message (warning or error) instead of throwing a fatal error.

We need to make several decisions:

  1. Should this "graceful" behavior should only be added for a local directory or whether it should be used for content in a git repository as well?
  2. At what the severity level should we log the message?
  3. How much should we decorate the log message in order to provide context for the user/author?

For (1), we may want to start with a local directory and then follow-up if we determine this behavior should be extented to content in git repositories as well.

For (2), I think we should use different severity levels for different problems.

  • warn - if file is not found (which means it disappeared)
  • error - if a symbolic link is invalid
  • error - any read issue (such as EPERM)

For (3), here are three ways we can write the message:

as thrown

WARN (@antora/content-aggregator): ENOENT: no such file or directory, lstat /path/to/antora/docs/modules/ROOT/pages/foobar.adoc

relative to scan dir (which is the content root)

WARN (@antora/content-aggregator): ENOENT: no such file or directory, lstat modules/ROOT/pages/foobar.adoc in /path/to/antora/docs

relative to content root, with content root info

WARN (@antora/content-aggregator): ENOENT: no such file or directory, lstat modules/ROOT/pages/foobar.adoc in /path/to/antora (ref: main <worktree> | path: docs)

structured log message

WARN (@antora/content-aggregator): ENOENT: no such file or directory, lstat modules/ROOT/pages/foobar.adoc
    file: /path/to/antora/docs/modules/ROOT/pages/foobar.adoc
    source: /path/to/antora (branch: main <worktree> | start path: docs)

The last one would be most consistent with how we're making log messages in Antora and is very achievable.

Edited by Dan Allen
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information