feat!: FFI logging options in Go open config; remove StartLogs#1535
feat!: FFI logging options in Go open config; remove StartLogs#1535
Conversation
Adds WithLogPath and WithLogFilter functional options to initialize env_logger via FFI at database open time. - Full `RUST_LOG` filter support via env_logger::Builder::parse_filters() - Log path required; use /dev/stdout for stdout; no defaults - Logging initialized before DB open; remains initialized even if open fails - Global per-process logger; fails when already initialized - Remove deprecated StartLogs and LogConfig from Go; keep fwd_start_logs called internally - Add trace log on Db::new() and comprehensive TestLogging covering error/success cases BREAKING CHANGE: StartLogs API removed; use WithLogPath/WithLogFilter options on New()
alarso16
left a comment
There was a problem hiding this comment.
I don't think we can do this until logs are supported per-database. Otherwise, we can't even make multiple databases in tests (since coreth Firewood doesn't know it's a test at instantiation). If this is added for the next release, I think I would just have to remove logging all together
| /// The file path where logs for this process are stored. | ||
| /// | ||
| /// If empty, this is set to `${TMPDIR}/firewood-log.txt`. | ||
| /// This is required and must not be empty. Use "/dev/stdout" for stdout logging. |
There was a problem hiding this comment.
We shouldn't recommend use of /dev/stdout as it will cause interleaving of the stdout from the parent process -- even if the parent process is also implemented Rust sharing the same stdlib statics.
- Any synchronization in Go around printing to stdout will be bypassed.
- Because
File::open("/dev/stdout")returns a new fd, any synchronization in Rust will also be bypassed.
| .filter_level(level) | ||
| .target(Pipe(Box::new(file))) | ||
| let mut builder = env_logger::Builder::new(); | ||
| builder.target(Pipe(Box::new(file))); |
There was a problem hiding this comment.
We should wrap file with std::io::BufWriter to make using stdout slightly more copacetic (doesn't prevent interleaving but makes it harder if we only write whole lines). env_logger calls flush after writing out every event.
We could still do this. If the database open fails because the logger is already initialized, just create the database with no logging. That would be a workaround until we implement per-database logging correctly. |
- Resolved conflicts in ffi/firewood.go (combined rootStore bool with logPath/logFilter) - Resolved conflicts in firewood/src/db.rs (changed db_path to db_dir, kept trace logging) - Updated DbConfig to use root_store: bool instead of root_store_dir: Option<PathBuf> - Updated all test helper methods to use new_with_config pattern
ca9aa37 to
a571bfb
Compare
- Resolved conflicts in ffi/firewood.go: Combined rootStore bool with logPath/logFilter from feature branch - Resolved conflicts in firewood/src/db.rs: Kept trace! logging from feature branch - Pulled in new changes from main including nextest config, CI workflow updates, and documentation improvements
Adds WithLogPath and WithLogFilter functional options to initialize env_logger via FFI at database open time.
RUST_LOGfilter support via env_logger::Builder::parse_filters()BREAKING CHANGE: StartLogs API removed; use WithLogPath/WithLogFilter options on New()
Why this should be merged
Now we support any logging option as configured from the go side, which means we probably need some configuration options in coreth to set up logging the way we want.
How this works
How this was tested
Workspace checks