Skip to content

Commit f0efec7

Browse files
authored
Fix compiling for Windows targets (dani-garcia#5053)
The `unix::signal` was also included during Windows compilations. This of course will not work. Fix this by only including it for `unix` targets. Also changed all other conditional compilation options to use `cfg(unix)` instead of `cfg(not(windows))`. The latter may also include `wasm` for example, or any other future target family. This way we will only match `unix` Fixes dani-garcia#5052
1 parent 040e2a7 commit f0efec7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ query_logger = ["dep:diesel_logger"]
3434
# Currently only used to enable rusts official ip support
3535
unstable = []
3636

37-
[target."cfg(not(windows))".dependencies]
37+
[target."cfg(unix)".dependencies]
3838
# Logging
3939
syslog = "6.1.1"
4040

src/main.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ use std::{
3838
use tokio::{
3939
fs::File,
4040
io::{AsyncBufReadExt, BufReader},
41-
signal::unix::SignalKind,
4241
};
4342

43+
#[cfg(unix)]
44+
use tokio::signal::unix::SignalKind;
45+
4446
#[macro_use]
4547
mod error;
4648
mod api;
@@ -383,15 +385,15 @@ fn init_logging() -> Result<log::LevelFilter, Error> {
383385
{
384386
logger = logger.chain(fern::log_file(log_file)?);
385387
}
386-
#[cfg(not(windows))]
388+
#[cfg(unix)]
387389
{
388390
const SIGHUP: i32 = SignalKind::hangup().as_raw_value();
389391
let path = Path::new(&log_file);
390392
logger = logger.chain(fern::log_reopen1(path, [SIGHUP])?);
391393
}
392394
}
393395

394-
#[cfg(not(windows))]
396+
#[cfg(unix)]
395397
{
396398
if cfg!(feature = "enable_syslog") || CONFIG.use_syslog() {
397399
logger = chain_syslog(logger);
@@ -441,7 +443,7 @@ fn init_logging() -> Result<log::LevelFilter, Error> {
441443
Ok(level)
442444
}
443445

444-
#[cfg(not(windows))]
446+
#[cfg(unix)]
445447
fn chain_syslog(logger: fern::Dispatch) -> fern::Dispatch {
446448
let syslog_fmt = syslog::Formatter3164 {
447449
facility: syslog::Facility::LOG_USER,

0 commit comments

Comments
 (0)