Skip to content

Commit

Permalink
Enable log module on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fenhl committed Jan 6, 2024
1 parent 878cec5 commit 29890a1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 54 deletions.
29 changes: 20 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions crate/wurstminebot-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ use {
cal,
config::Config,
http,
log,
minecraft::tellraw,
twitch,
},
};
#[cfg(unix)] use wurstminebot::log;

enum UserListExporter {}

Expand Down Expand Up @@ -464,16 +464,11 @@ async fn main() -> Result<serenity_utils::Builder, Error> {
notify_thread_crash(format!("HTTP server"), Box::new(e), None).await;
}
})
.task(|#[cfg_attr(not(unix), allow(unused))] ctx_fut, #[cfg_attr(not(unix), allow(unused))] notify_thread_crash| async move {
#[cfg(unix)] {
// follow the Minecraft log
if let Err(e) = log::handle(ctx_fut).await {
eprintln!("{}", e);
notify_thread_crash(format!("log"), Box::new(e), None).await;
}
}
#[cfg(not(unix))] {
eprintln!("warning: Minecraft log analysis is only supported on cfg(unix) because of https://github.com/lloydmeta/chase-rs/issues/6");
.task(|ctx_fut, notify_thread_crash| async move {
// follow the Minecraft log
if let Err(e) = log::handle(ctx_fut).await {
eprintln!("{}", e);
notify_thread_crash(format!("log"), Box::new(e), None).await;
}
})
.task(|ctx_fut, notify_thread_crash| async move {
Expand Down
60 changes: 29 additions & 31 deletions crate/wurstminebot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,43 @@ warnings = "deny"

[dependencies]
chrono = "0.4"
futures = "0.3"
ics = "0.5"
itertools = "0.12"
lazy-regex = "3"
rcon = "0.6"
regex = "1"
rocket = "0.5"
serde_json = "1" #TODO make sure enabling the arbitrary_precision feature doesn't break anything
serenity = "0.12"
thiserror = "1"

[dependencies.async_zip]
version = "0.0.16"
features = ["full"]

[dependencies.chase]
git = "https://github.com/fenhl/chase-rs"
branch = "dev-fenhl"
features = ["stream"]

[dependencies.derive_more]
version = "0.99"
default-features = false
features = ["from"]

[dependencies.futures]
version = "0.3"
features = ["compat"]

[dependencies.minecraft]
git = "https://github.com/wurstmineberg/rust-minecraft-types"
branch = "main"

[dependencies.reqwest]
version = "0.11"
default-features = false
features = ["rustls-tls", "trust-dns"]

[dependencies.rocket-util]
git = "https://github.com/fenhl/rocket-util"
branch = "main"
Expand Down Expand Up @@ -62,6 +80,14 @@ package = "minecraft"
version = "1.3"
features = ["fs", "macros", "parking_lot", "sync", "rt-multi-thread"]

[dependencies.tokio-stream]
version = "0.1"
features = ["io-util"]

[dependencies.tokio-util]
version = "0.7"
features = ["io"]

[dependencies.twitch-irc]
version = "5"
default-features = false
Expand All @@ -71,39 +97,11 @@ features = ["transport-tcp-rustls-webpki-roots"]
git = "https://github.com/fenhl/rust-twitch-helix" #TODO publish to crates.io
branch = "main"

[target.'cfg(unix)'.dependencies]
regex = "1"

[target.'cfg(unix)'.dependencies.async_zip]
version = "0.0.16"
features = ["full"]

[target.'cfg(unix)'.dependencies.chase]
version = "0.1"
features = ["stream"]

[target.'cfg(unix)'.dependencies.futures]
version = "0.3"
features = ["compat"]

[target.'cfg(unix)'.dependencies.reqwest]
version = "0.11"
default-features = false
features = ["rustls-tls", "trust-dns"]

[target.'cfg(unix)'.dependencies.tokio-stream]
version = "0.1"
features = ["io-util"]

[target.'cfg(unix)'.dependencies.tokio-util]
version = "0.7"
features = ["io"]

[target.'cfg(unix)'.dependencies.url]
[dependencies.url]
version = "2"
features = ["serde"]

[target.'cfg(unix)'.dependencies.wheel]
[dependencies.wheel]
git = "https://github.com/fenhl/wheel"
branch = "main"
features = ["reqwest", "serde", "serde_json"]
4 changes: 2 additions & 2 deletions crate/wurstminebot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod cal;
pub mod config;
pub mod http;
pub mod ipc;
#[cfg(unix)] pub mod log;
pub mod log;
pub mod minecraft;
pub mod parse;
pub mod people;
Expand Down Expand Up @@ -47,7 +47,7 @@ pub enum Error {
#[error(transparent)] Ipc(#[from] crate::ipc::Error),
#[error(transparent)] Join(#[from] tokio::task::JoinError),
#[error(transparent)] Json(#[from] serde_json::Error),
#[cfg(unix)] #[error(transparent)] Log(#[from] log::Error),
#[error(transparent)] Log(#[from] log::Error),
#[error(transparent)] Minecraft(#[from] systemd_minecraft::Error),
#[error(transparent)] Serenity(#[from] serenity::Error),
#[error(transparent)] Sql(#[from] sqlx::Error),
Expand Down
2 changes: 1 addition & 1 deletion crate/wurstminebot/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn follow(http_client: reqwest::Client, world: &World) -> impl Stream<Item = Res
.map_err(|()| Error::Channel)
.scan(
Arc::new(RwLock::new(FollowerState {
minecraft_version: None /*TODO check log history for current Minecraft version */,
minecraft_version: None, //TODO check log history for current Minecraft version
death_messages: HashMap::default(),
http_client,
})),
Expand Down

0 comments on commit 29890a1

Please sign in to comment.