Skip to content

Commit 2be6a78

Browse files
committed
docs: improve convenience log fns
The convenience log functions weren't clear as to what they actually did internally. So I have updated the docs to make this explicit. Signed-off-by: JP-Ellis <[email protected]>
1 parent e2d2ca3 commit 2be6a78

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

rust/pact_ffi/src/log/ffi.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ use crate::log::status::Status;
1717
use crate::util::string::to_c;
1818

1919
/// Convenience function to direct all logging to stdout.
20+
///
21+
/// This function is equivalent to using [`pactffi_logger_init`] followed by the
22+
/// [`pactffi_logger_attach_sink`] with the appropriate sink specifier, and then
23+
/// [`pactffi_logger_apply`].
2024
#[no_mangle]
2125
pub extern "C" fn pactffi_log_to_stdout(level_filter: LevelFilter) -> c_int {
2226
pactffi_logger_init();
@@ -43,6 +47,10 @@ pub extern "C" fn pactffi_log_to_stdout(level_filter: LevelFilter) -> c_int {
4347
}
4448

4549
/// Convenience function to direct all logging to stderr.
50+
///
51+
/// This function is equivalent to using [`pactffi_logger_init`] followed by the
52+
/// [`pactffi_logger_attach_sink`] with the appropriate sink specifier, and then
53+
/// [`pactffi_logger_apply`].
4654
#[no_mangle]
4755
pub extern "C" fn pactffi_log_to_stderr(level_filter: LevelFilter) -> c_int {
4856
pactffi_logger_init();
@@ -70,7 +78,13 @@ pub extern "C" fn pactffi_log_to_stderr(level_filter: LevelFilter) -> c_int {
7078

7179
/// Convenience function to direct all logging to a file.
7280
///
81+
///
82+
/// This function is equivalent to using [`pactffi_logger_init`] followed by the
83+
/// [`pactffi_logger_attach_sink`] with the appropriate sink specifier, and then
84+
/// [`pactffi_logger_apply`].
85+
///
7386
/// # Safety
87+
///
7488
/// This function will fail if the file_name pointer is invalid or does not point to a NULL
7589
/// terminated string.
7690
#[no_mangle]
@@ -118,8 +132,14 @@ pub unsafe extern "C" fn pactffi_log_to_file(
118132
Status::Success as c_int
119133
}
120134

121-
122135
/// Convenience function to direct all logging to a task local memory buffer.
136+
///
137+
/// This function is equivalent to using [`pactffi_logger_init`] followed by the
138+
/// [`pactffi_logger_attach_sink`] with the appropriate sink specifier, and then
139+
/// [`pactffi_logger_apply`].
140+
///
141+
/// The contents of the buffer can be fetched using
142+
/// [`pactffi_fetch_log_buffer`].
123143
#[no_mangle]
124144
pub extern "C" fn pactffi_log_to_buffer(level_filter: LevelFilter) -> c_int {
125145
pactffi_logger_init();

0 commit comments

Comments
 (0)