Skip to content

Commit b389db7

Browse files
committed
Move remaining macros to gdnative::log
1 parent cd8f5df commit b389db7

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

gdnative-core/src/log.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
use std::ffi::CStr;
33
use std::fmt::{self, Display};
44

5+
// Collection of macros accessing the Godot engine log/print functionality
6+
pub use crate::{godot_dbg, godot_error, godot_print, godot_site, godot_warn};
7+
58
use crate::core_types::GodotString;
69
use crate::private;
710

811
/// Value representing a call site for errors and warnings. Can be constructed
9-
/// using the `godot_site!` macro, or manually.
12+
/// using the [`godot_site`] macro, or manually.
1013
#[derive(Copy, Clone, Debug)]
1114
pub struct Site<'a> {
1215
file: &'a CStr,
@@ -45,6 +48,8 @@ impl<'a> Display for Site<'a> {
4548

4649
/// Print a message to the Godot console.
4750
///
51+
/// Typically, you would use this through the [`godot_print`] macro.
52+
///
4853
/// # Panics
4954
///
5055
/// If the API isn't initialized.
@@ -58,6 +63,8 @@ pub fn print<S: Display>(msg: S) {
5863

5964
/// Print a warning to the Godot console.
6065
///
66+
/// Typically, you would use this through the [`godot_warn`] macro.
67+
///
6168
/// # Panics
6269
///
6370
/// If the API isn't initialized, or if the message contains any NUL-bytes.
@@ -78,6 +85,8 @@ pub fn warn<S: Display>(site: Site<'_>, msg: S) {
7885

7986
/// Print an error to the Godot console.
8087
///
88+
/// Typically, you would use this through the [`godot_error`] macro.
89+
///
8190
/// # Panics
8291
///
8392
/// If the API isn't initialized, or if the message contains any NUL-bytes.

gdnative-core/src/macros.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@ macro_rules! godot_dbg {
3535
};
3636
}
3737

38-
/// Creates a `gdnative::log::Site` value from the current position in code,
38+
/// Creates a [`Site`][crate::log::Site] value from the current position in code,
3939
/// optionally with a function path for identification.
4040
///
4141
/// # Examples
4242
///
4343
/// ```ignore
44+
/// use gdnative::log;
45+
///
4446
/// // WARN: <unset>: foo At: path/to/file.rs:123
45-
/// gdnative::log::warn(godot_site!(), "foo");
47+
/// log::warn(log::godot_site!(), "foo");
48+
///
4649
/// // WARN: Foo::my_func: bar At: path/to/file.rs:123
47-
/// gdnative::log::error(godot_site!(Foo::my_func), "bar");
50+
/// log::error(log::godot_site!(Foo::my_func), "bar");
4851
/// ```
4952
#[macro_export]
5053
macro_rules! godot_site {

gdnative/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@
6060
#[doc(inline)]
6161
pub use gdnative_core::{core_types, export, init, log, object, profiler};
6262

63-
/// Collection of declarative `godot_*` macros, mostly for GDNative registration and output.
64-
pub mod macros {
65-
pub use gdnative_core::{godot_dbg, godot_error, godot_print, godot_warn};
66-
}
67-
6863
// Implementation details (e.g. used by macros).
6964
// However, do not re-export macros (on crate level), thus no wildcard
7065
#[doc(hidden)]

0 commit comments

Comments
 (0)