spkenv / spk

A Package Manager for high velocity software environments, built on spfs.
https://spkenv.dev
Apache License 2.0
40 stars 6 forks source link

Add `--output-to-dir <path>` for solvers' output #1067

Closed dcookspi closed 3 months ago

dcookspi commented 4 months ago

Adds --output-to-dir <path> flag for logging each solver's output to a separate file for each solver run, and the SPK_OUTPUT_TO_DIR env avr. The output files will be put in the given path.

It extends the OutputKind enum to have entries that output to a file, or println! and a file, or tracing! and a file. The interface allows for anything with the Write trait (and some thread-safe/task required traits). The Copy trait was removed from the enum in favour of cloning while wrangling the tasks, threads, mutability, and task communication messages. Let me know if there's a better way to do this.

A method was added to the enum to allow the initial output kind, i.e. Println or Tracing, to be combined with an output to file enum entry. This is used to make things appear in the right places when a background solver finishes the solve first and needs to print the solve results for the user (Installed Packages: ...).

The solve output files are named with the date and time the solve started, and the name of the kind of solver, e.g.

The verbosity level is increased to at least 2 when --output-to-dir ... is used. This helps ensure the files contain enough solver information to be useful when debugging issues. This minimum verbosity level is configurable via --output-to-dir-min-verbosity <n> or the SPK.SPK_OUTPUT_TO_DIR_MIN_VERBOSITY env var).

dcookspi commented 4 months ago

Still can't have 2 reviewers on PRs. So @rydrman, @jrray mentioning you both here, so you see this one.

dcookspi commented 4 months ago

Going to add env vars and a way to control the file logging verbosity for solvers. We want to be able to set env var so CI jobs all log to files at a minimal verbosity that will be useful for tracing issues.

dcookspi commented 4 months ago

Updated to have a minimum verbosity when outputting to files is enabled. Changed over to output to dir and ot take a directory path to the place the solver files will be written to. Added subsecond time numbers to the filenames to cope with multiple solver runs in the same second. Changes output file creation to catch existing file issues and try again with a different file name. Added --output-file-prefix and an env var to allow the first part of the filename to overridden.