Merge pull request #11 from pop-os/log_jammy
Don't log output of cosmic-comp/cosmic-panel, log panics
This commit is contained in:
commit
fa898f9228
4 changed files with 56 additions and 80 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -232,6 +232,7 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"launch-pad",
|
"launch-pad",
|
||||||
"libc",
|
"libc",
|
||||||
|
"log-panics",
|
||||||
"nix 0.25.0",
|
"nix 0.25.0",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
"sendfd",
|
"sendfd",
|
||||||
|
|
@ -484,6 +485,16 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log-panics"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68f9dd8546191c1850ecf67d22f5ff00a935b890d0e84713159a55495cc2ac5f"
|
||||||
|
dependencies = [
|
||||||
|
"backtrace",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matchers"
|
name = "matchers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ color-eyre = "0.6"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
launch-pad = { git = "https://github.com/pop-os/launch-pad" }
|
launch-pad = { git = "https://github.com/pop-os/launch-pad" }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
log-panics = { version = "2", features = ["with-backtrace"] }
|
||||||
nix = { version = "0.25", features = ["fs"], default-features = false }
|
nix = { version = "0.25", features = ["fs"], default-features = false }
|
||||||
scopeguard = "1"
|
scopeguard = "1"
|
||||||
sendfd = { version = "0.4", features = ["tokio"] }
|
sendfd = { version = "0.4", features = ["tokio"] }
|
||||||
|
|
|
||||||
29
src/comp.rs
29
src/comp.rs
|
|
@ -14,7 +14,6 @@ use tokio::{
|
||||||
task::JoinHandle,
|
task::JoinHandle,
|
||||||
};
|
};
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
use tracing::Instrument;
|
|
||||||
|
|
||||||
use crate::process::mark_as_not_cloexec;
|
use crate::process::mark_as_not_cloexec;
|
||||||
|
|
||||||
|
|
@ -191,34 +190,14 @@ pub fn run_compositor(
|
||||||
OwnedFd::from(std_stream)
|
OwnedFd::from(std_stream)
|
||||||
};
|
};
|
||||||
mark_as_not_cloexec(&comp).expect("Failed to mark fd as not cloexec");
|
mark_as_not_cloexec(&comp).expect("Failed to mark fd as not cloexec");
|
||||||
// Create a new span, marking the upcoming task as `cosmic-comp` with tracing.
|
Ok(tokio::spawn(async move {
|
||||||
let span = info_span!(parent: None, "cosmic-comp");
|
|
||||||
let _span = span.clone();
|
|
||||||
Ok(tokio::spawn(
|
|
||||||
async move {
|
|
||||||
// Create a new process handler for cosmic-comp, with our compositor socket's
|
// Create a new process handler for cosmic-comp, with our compositor socket's
|
||||||
// file descriptor as the `COSMIC_SESSION_SOCK` environment variable.
|
// file descriptor as the `COSMIC_SESSION_SOCK` environment variable.
|
||||||
let stdout_span = span.clone();
|
|
||||||
let stderr_span = span.clone();
|
|
||||||
process_manager
|
process_manager
|
||||||
.start_process(
|
.start_process(
|
||||||
Process::new()
|
Process::new()
|
||||||
.with_executable("cosmic-comp")
|
.with_executable("cosmic-comp")
|
||||||
.with_env([("COSMIC_SESSION_SOCK", comp.as_raw_fd().to_string())])
|
.with_env([("COSMIC_SESSION_SOCK", comp.as_raw_fd().to_string())]),
|
||||||
.with_on_stdout(move |_, _, line| {
|
|
||||||
let stdout_span = stdout_span.clone();
|
|
||||||
async move {
|
|
||||||
info!("{}", line);
|
|
||||||
}
|
|
||||||
.instrument(stdout_span)
|
|
||||||
})
|
|
||||||
.with_on_stderr(move |_, _, line| {
|
|
||||||
let stderr_span = stderr_span.clone();
|
|
||||||
async move {
|
|
||||||
warn!("{}", line);
|
|
||||||
}
|
|
||||||
.instrument(stderr_span)
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect("failed to launch compositor");
|
.expect("failed to launch compositor");
|
||||||
|
|
@ -249,7 +228,5 @@ pub fn run_compositor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Result::<()>::Ok(())
|
Result::<()>::Ok(())
|
||||||
}
|
}))
|
||||||
.instrument(_span),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
src/main.rs
27
src/main.rs
|
|
@ -34,6 +34,7 @@ async fn main() -> Result<()> {
|
||||||
)
|
)
|
||||||
.try_init()
|
.try_init()
|
||||||
.wrap_err("failed to initialize logger")?;
|
.wrap_err("failed to initialize logger")?;
|
||||||
|
log_panics::init();
|
||||||
|
|
||||||
info!("Starting cosmic-session");
|
info!("Starting cosmic-session");
|
||||||
|
|
||||||
|
|
@ -61,28 +62,11 @@ async fn main() -> Result<()> {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
info!("got environmental variables: {:?}", env_vars);
|
info!("got environmental variables: {:?}", env_vars);
|
||||||
|
|
||||||
let span = info_span!(parent: None, "cosmic-panel");
|
|
||||||
let stdout_span = span.clone();
|
|
||||||
let stderr_span = span.clone();
|
|
||||||
process_manager
|
process_manager
|
||||||
.start(
|
.start(
|
||||||
Process::new()
|
Process::new()
|
||||||
.with_executable("cosmic-panel")
|
.with_executable("cosmic-panel")
|
||||||
.with_env(env_vars.clone())
|
.with_env(env_vars.clone()),
|
||||||
.with_on_stdout(move |_, _, line| {
|
|
||||||
let stdout_span = stdout_span.clone();
|
|
||||||
async move {
|
|
||||||
info!("{}", line);
|
|
||||||
}
|
|
||||||
.instrument(stdout_span)
|
|
||||||
})
|
|
||||||
.with_on_stderr(move |_, _, line| {
|
|
||||||
let stderr_span = stderr_span.clone();
|
|
||||||
async move {
|
|
||||||
warn!("{}", line);
|
|
||||||
}
|
|
||||||
.instrument(stderr_span)
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.expect("failed to start panel");
|
.expect("failed to start panel");
|
||||||
|
|
@ -173,9 +157,12 @@ async fn main() -> Result<()> {
|
||||||
let (exit_tx, exit_rx) = oneshot::channel();
|
let (exit_tx, exit_rx) = oneshot::channel();
|
||||||
let _ = ConnectionBuilder::session()?
|
let _ = ConnectionBuilder::session()?
|
||||||
.name("com.system76.CosmicSession")?
|
.name("com.system76.CosmicSession")?
|
||||||
.serve_at("/com/system76/CosmicSession", service::SessionService {
|
.serve_at(
|
||||||
|
"/com/system76/CosmicSession",
|
||||||
|
service::SessionService {
|
||||||
exit_tx: Some(exit_tx),
|
exit_tx: Some(exit_tx),
|
||||||
})?
|
},
|
||||||
|
)?
|
||||||
.build()
|
.build()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue