xref: /aosp_15_r20/external/crosvm/base/src/sys/windows/syslog.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1 // Copyright 2022 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 //! Facilities for sending log message to syslog.
6 //!
7 //! Every function exported by this module is thread-safe. Each function will silently fail until
8 //! `syslog::init()` is called and returns `Ok`.
9 //!
10 //! # Examples
11 //!
12 //! ```
13 //! use base::{error, self, warn};
14 //!
15 //! if let Err(e) = base::syslog::init() {
16 //!     println!("failed to initiailize syslog: {}", e);
17 //!     return;
18 //! }
19 //! warn!("this is your {} warning", "final");
20 //! error!("something went horribly wrong: {}", "out of RAMs");
21 //! ```
22 
23 use crate::syslog::Error;
24 use crate::syslog::Facility;
25 use crate::syslog::Log;
26 use crate::syslog::Syslog;
27 use crate::RawDescriptor;
28 
29 // SAFETY:
30 // On windows RawDescriptor is !Sync + !Send, but also on windows we don't do anything with them
31 unsafe impl Sync for crate::syslog::State {}
32 // SAFETY: See comments for impl Sync
33 unsafe impl Send for crate::syslog::State {}
34 
35 pub struct PlatformSyslog {}
36 
37 impl Syslog for PlatformSyslog {
new( _proc_name: String, _facility: Facility, ) -> Result<(Option<Box<dyn Log + Send>>, Option<RawDescriptor>), Error>38     fn new(
39         _proc_name: String,
40         _facility: Facility,
41     ) -> Result<(Option<Box<dyn Log + Send>>, Option<RawDescriptor>), Error> {
42         Ok((None, None))
43     }
44 }
45