* Add support for Rust in CMake via Corrosion * Tweak .gitignore to handle Rust target dir * It's 3AM and I have no desire to deal with this * Initial scaffolding for loading Rust library in Dolphin * Expose the Dolphin logging mechanisms to Rust via some callback trickery * Attempt patching Core.vcxproj to support building Rust dylib * Attempt patching Core.vcxproj to support building Rust dylib, take 2 OR * Instruct the build to actually use the steps * Attempt the older style vcxproj definition format * Push build targets to end * Just don't use va_args when calling through from Rust * Enable Windows project linking, move to generic project structure, start moving out of HW * Add note to README about Rust requirement * Update slippi-rust-extensions to have proper EXI Device skeleton * Attach shadow EXI device to cpp EXI device, add feature flag for playback-specific code, rewrite README for rust extensions slightly * Remove unused log file * Ongoing logging work * Tweak Dolphin LogContainer to auto forward enabled/level status over to Rust, expose more methods on Rust side for control, rebuild logger layer subscriber * Remove debug flag for release mode but add note about it * Reorganize module definitions, pass in sampler handler fn for SoundStream * Fix log target * Rename to SlippiRustExtensions, separate out into cargo workspace, rename General Rust log * Tweak logging layer so that we don't double-allocate strings on all log messages, properly surface log locations * cargo fmt * initial port of slippi-jukebox code * minor cleanup and leverage channels rather than atomic bool for stopping threads * Add config option for enabling/disabling Jukebox * Invert shutdown order for Memory and ExpansionInterface so we avoid a null ptr race in the Jukebox, as we need Memory to still be valid at Jukebox shutdown * update dolphin additional include dirs to facilitate new slippi config pane changes * Ensure Core is running before trying to find an EXI device, as ExpansionInterface isn't initialized unless Core is running - fixes a crash on bad access * Expose streaming sampler to jukebox, disable DVDInterface streaming sampler pushes to avoid null data being pushed in * Expose setters for streaming sample rate and streaming volume to Rust * jukebox: renaming variables for clarity * try to use new jukebox sample functions * jukebox: add support for all star rest area * jukebox: add support for adventure mode field stages * jukebox: continuously send chunks of pcm data to dolphin's audio mixer * Audio somewhat coming through now, albeit with pops and pitch issues... * Force-log samples to wav * jukebox: switch from dolphin mixer back to rodio for music playback * Mark doc example as notest * Attempt an initial CI pass * Tinkering with CI * Specify CI working directory for cargo fmt * Specify CI working directory for cargo fmt * Specify CI working directory for cargo fmt * Specify CI working directory for cargo fmt * Specify CI working directory for cargo fmt * Specify CI working directory for cargo fmt * [CI] More permissive for compiling code * jukebox: replace rand with fastrand * jukebox: dont use static memory for menu & tournament tracks * Attempt to resolve Windows playback lib loading oddity * Add a method for grabbing the current volume level * Have Dolphin pass over the iso path and a getter for the volume level * Cargo fmt pass * Include rustfmt.toml * Remove the Jukebox config option from playback builds entirely, do not start the jukebox if we're in WASAPI Exclusive mode * Ix-nay the bad check I copied by accident, lol * SlippiRustExtensions: add build instructions for windows * jukebox: make proper use of dolphin's volume + remove unused dependencies * SlippiRustExtensions(readme): simplify suggested out-of-band build command * jukebox: remove 'anyhow' dependency * jukebox: simplify read_dolphin_state fn * jukebox: reduce hps fingerprint size for track matching * jukebox: remove 'bus' dependency and improve comments * jukebox: add readme * jukebox: add description field to Cargo.toml * README cleanup, extra writeup for logcontainer creation * Cleanup unused imports * Rename DolphinState to DolphinGameState * Pin to Rust 1.70.0 * Re-enable SFX, stop force-dumping WAV DTK audiograph logs * Revert attempted change of disabling DTK reads * Revise documentation surrounding logging infrastructure changes * Ensure the Volume getter is outside of a C++ namespace, just to try and be careful with ABI oddities * Add an extra LogContainer. - A generic Rust dependencies log container that we can use if we need to ever inspect dependency tracing logs. - Moves the AudioCommon::GetVolume call out of the namespace for now since I want someone (or me, when I get more time) to verify that being inside a C++ namespace is safe. - Remove once_cell as a dependency now that this is pinned to `1.70.0`. * Fix the typo, because C++ * Additional README contexts * ifndef PLAYBACK for GUI toggles * Always publish an artifact for macOS even if we're not signing and notarizing * Try changing into the directory - why is there so little documentation about what is supported in these files...? * Pin toolchain in CI to 1.70.0, update Visual Studio to change into working directory for pre-build Rust step so that toolchain file is actually detected * Opt for a root symlink to the toolchain config per Nikki's idea, comment out forced 1.70.0 in CI build flow * Revert symlink toolchain to see if there's a CI bug for Linux * jukebox: reduce music volume by 20% * jukebox: link to hps_decode crate in the docs * ci: sed out rust version from rust-toolchain.toml * ci: add id field for rust_ver * jukebox: stop blocking the main thread when scanning iso for tracks * jukebox: respect melee's volume setting when restarting jukebox during emulation * jukebox: improve code readability * jukebox: leverage disc filesystem table to locate .hps files * jukebox: minor fst parsing code improvements * remove '.unwrap()' from Jukebox destructor --------- Co-authored-by: Ryan McGrath <ryan@rymc.io> Co-authored-by: Nikhil Narayana <nikhil.narayana@live.com>
3.0 KiB
Dolphin-Logger
This crate implements a custom tracing-subscriber that handles shuttling logs through the Dolphin application logging infrastructure. This is important not just for keeping logs contained all in one place, but for aiding in debugging on Windows where console logging is... odd.
How it works
The first thing to understand is that the Slippi Dolphin LogManager
module has some tweaks to support creating a "Rust-sourced" LogContainer
.
When the LogManager
is created, we initialize the Rust logging framework by calling slprs_logging_init
, passing a function to dispatch logs through from the Rust side.
The LogManager
has several LogContainer
instances, generally corresponding to a particular grouping of log types. If a LogContainer
is flagged as sourcing from the Rust library, then on instantiation it will register itself with the Rust logger by calling slprs_logging_register_container
. This registration call caches the LogType
and enabled status of the log so that the Rust side can transparently keep track of things and not have to concern itself with any changing enum variant types.
When a Rust-sourced LogContainer
is updated - say, a status change to disabled
- it will forward this change to the Rust side via slprs_logging_update_container
. If a log container is disabled in Rust, then logs are dropped accordingly with no allocations made anywhere (i.e, nothing should be impacting gameplay).
Adding a new LogContainer
If you need to add a new log to the Dolphin codebase, you will need to add a few lines to the log definitions on the C++ side. This enables using the Dolphin logs viewer to monitor Rust tracing
events.
First, head to Source/Core/Common/Logging/Log.h
and define a new LogTypes::LOG_TYPE
variant.
Next, head to Source/Core/Common/Logging/LogManager.cpp
and add a new LogContainer
in LogManager::LogManager()
. For example, let's say that we created LogTypes::SLIPPI_RUST_EXI
- we'd now add:
// This LogContainer will register with the Rust side under the "SLIPPI_RUST_EXI" target.
m_Log[LogTypes::SLIPPI_RUST_EXI] = new LogContainer(
"SLIPPI_RUST_EXI", // Internal identifier, Rust will need to match
"Slippi EXI (Rust)", // User-visible log label
LogTypes::SLIPPI_RUST_EXI, // The C++ LogTypes variant we created
true // Instructs the initializer that this is a Rust-sourced log
);
Finally, add an associated const
declaration with your LogContainer
internal identifier in src/lib.rs
:
pub mod Log {
// ...other logs etc
// Our new logger name
pub const EXI: &'static str = "SLIPPI_RUST_EXI";
}
Now your Rust module can specify that it should log to this container via the tracing module:
use dolphin_logger::Log;
fn do_stuff() {
tracing::info!(target: Log::EXI, "Hello from the Rust side");
}
Make sure to enable your log via Dolphin's Log Manager view to see these logs!