Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/base/src/sys/windows/syslog.rs
5394 views
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 {
38
fn new(
39
_proc_name: String,
40
_facility: Facility,
41
) -> Result<(Option<Box<dyn Log + Send>>, Option<RawDescriptor>), &'static Error> {
42
Ok((None, None))
43
}
44
}
45
46