summary refs log tree commit diff
path: root/sys_util/src/syslog.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-04-12 11:27:37 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-15 02:06:04 -0700
commita70a2193ad10a6e0f2e28c45a2e75fff6a102f22 (patch)
tree6e001f53cfdeed7bdd0f10b15ce2ef56d9226360 /sys_util/src/syslog.rs
parent1b7f3ed23505b83343b376c8d8777366457402d0 (diff)
downloadcrosvm-a70a2193ad10a6e0f2e28c45a2e75fff6a102f22.tar
crosvm-a70a2193ad10a6e0f2e28c45a2e75fff6a102f22.tar.gz
crosvm-a70a2193ad10a6e0f2e28c45a2e75fff6a102f22.tar.bz2
crosvm-a70a2193ad10a6e0f2e28c45a2e75fff6a102f22.tar.lz
crosvm-a70a2193ad10a6e0f2e28c45a2e75fff6a102f22.tar.xz
crosvm-a70a2193ad10a6e0f2e28c45a2e75fff6a102f22.tar.zst
crosvm-a70a2193ad10a6e0f2e28c45a2e75fff6a102f22.zip
sys_util: Enable macros imported individually
The syslog and ioctl macros in sys_util were originally written to be
imported through `#[macro_use] extern crate sys_util` which is
essentially a glob import of all macros from the crate.

In 2018 edition, extern crate is deprecated and macros are imported the
same as any other item. As these sys_util macros are currently written,
importing an individual macro requires the caller to also import any
other sys_util macros that the invocation internally expands to.
Example:

    use sys_util::{error, log};

    fn main() {
        error!("...");
    }

This CL adjusts all sys_util macros to invoke helper macros through a
`$crate::` prefix so that the caller is not required to have the helper
macros in scope themselves.

    use sys_util::error;

    fn main() {
        error!("...");
    }

TEST=kokoro

Change-Id: I2d9f16dca8e7a4a4c0e63d9f10ead9f7413d9c3c
Reviewed-on: https://chromium-review.googlesource.com/1565544
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'sys_util/src/syslog.rs')
-rw-r--r--sys_util/src/syslog.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/sys_util/src/syslog.rs b/sys_util/src/syslog.rs
index a87a2ea..af5cefc 100644
--- a/sys_util/src/syslog.rs
+++ b/sys_util/src/syslog.rs
@@ -10,9 +10,7 @@
 //! # Examples
 //!
 //! ```
-//! #[macro_use] extern crate sys_util;
-//!
-//! use sys_util::syslog;
+//! use sys_util::{error, syslog, warn};
 //!
 //! fn main() {
 //!     if let Err(e) = syslog::init() {
@@ -396,7 +394,6 @@ fn get_localtime() -> tm {
 /// # Examples
 ///
 /// ```
-/// # #[macro_use] extern crate sys_util;
 /// # use sys_util::syslog;
 /// # fn main() {
 /// #   if let Err(e) = syslog::init() {
@@ -479,7 +476,7 @@ macro_rules! log {
 /// Note that this will fail silently if syslog was not initialized.
 #[macro_export]
 macro_rules! error {
-    ($($args:tt)+) => (log!($crate::syslog::Priority::Error, $($args)*))
+    ($($args:tt)+) => ($crate::log!($crate::syslog::Priority::Error, $($args)*))
 }
 
 /// A macro for logging a warning.
@@ -487,7 +484,7 @@ macro_rules! error {
 /// Note that this will fail silently if syslog was not initialized.
 #[macro_export]
 macro_rules! warn {
-    ($($args:tt)+) => (log!($crate::syslog::Priority::Warning, $($args)*))
+    ($($args:tt)+) => ($crate::log!($crate::syslog::Priority::Warning, $($args)*))
 }
 
 /// A macro for logging info.
@@ -495,7 +492,7 @@ macro_rules! warn {
 /// Note that this will fail silently if syslog was not initialized.
 #[macro_export]
 macro_rules! info {
-    ($($args:tt)+) => (log!($crate::syslog::Priority::Info, $($args)*))
+    ($($args:tt)+) => ($crate::log!($crate::syslog::Priority::Info, $($args)*))
 }
 
 /// A macro for logging debug information.
@@ -503,7 +500,7 @@ macro_rules! info {
 /// Note that this will fail silently if syslog was not initialized.
 #[macro_export]
 macro_rules! debug {
-    ($($args:tt)+) => (log!($crate::syslog::Priority::Debug, $($args)*))
+    ($($args:tt)+) => ($crate::log!($crate::syslog::Priority::Debug, $($args)*))
 }
 
 #[cfg(test)]