fix: use diagnostic instead of compilermessage giving rendered ansi logs during hotpatch (#4123)
* fix: use diagnostic instead of compilermessage giving rendered ansi logs during hotpatch * no need for builder
This commit is contained in:
1 parent
0a18c12c32
commit
b610ab372c
6 files changed
+24
-14
No files matched your search
@@ -380,7 +380,7 @@ impl AppBuilder {
|
||||
tracing::info!(json = ?StructuredOutput::BuildUpdate { stage: stage.clone() });
|
||||
}
|
||||
BuilderUpdate::CompilerMessage { message } => {
|
||||
tracing::info!(json = ?StructuredOutput::CargoOutput { message: message.clone() }, %message);
|
||||
tracing::info!(json = ?StructuredOutput::RustcOutput { message: message.clone() }, %message);
|
||||
}
|
||||
BuilderUpdate::BuildReady { bundle } => {
|
||||
tracing::debug!(json = ?StructuredOutput::BuildFinished {
|
||||
@@ -392,7 +392,7 @@ impl AppBuilder {
|
||||
// Flush remaining compiler messages
|
||||
while let Ok(Some(msg)) = self.rx.try_next() {
|
||||
if let BuilderUpdate::CompilerMessage { message } = msg {
|
||||
tracing::info!(json = ?StructuredOutput::CargoOutput { message: message.clone() }, %message);
|
||||
tracing::info!(json = ?StructuredOutput::RustcOutput { message: message.clone() }, %message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use super::BuildMode;
|
||||
use crate::{BuildArtifacts, BuildStage, Error, TraceSrc};
|
||||
use cargo_metadata::CompilerMessage;
|
||||
use cargo_metadata::diagnostic::Diagnostic;
|
||||
use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{path::PathBuf, process::ExitStatus};
|
||||
@@ -35,7 +35,7 @@ pub enum BuilderUpdate {
|
||||
},
|
||||
|
||||
CompilerMessage {
|
||||
message: CompilerMessage,
|
||||
message: Diagnostic,
|
||||
},
|
||||
|
||||
BuildReady {
|
||||
@@ -92,7 +92,7 @@ impl BuildContext {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn status_build_diagnostic(&self, message: CompilerMessage) {
|
||||
pub(crate) fn status_build_diagnostic(&self, message: Diagnostic) {
|
||||
_ = self
|
||||
.tx
|
||||
.unbounded_send(BuilderUpdate::CompilerMessage { message });
|
||||
|
||||
@@ -320,6 +320,7 @@ use crate::{
|
||||
TargetArgs, TraceSrc, WasmBindgen, WasmOptConfig, Workspace, DX_RUSTC_WRAPPER_ENV_VAR,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use cargo_metadata::diagnostic::Diagnostic;
|
||||
use dioxus_cli_config::format_base_path_meta_element;
|
||||
use dioxus_cli_config::{APP_TITLE_ENV, ASSET_ROOT_ENV};
|
||||
use dioxus_cli_opt::{process_file_to, AssetManifest};
|
||||
@@ -807,7 +808,7 @@ impl BuildRequest {
|
||||
|
||||
match message {
|
||||
Message::BuildScriptExecuted(_) => units_compiled += 1,
|
||||
Message::CompilerMessage(msg) => ctx.status_build_diagnostic(msg),
|
||||
Message::CompilerMessage(msg) => ctx.status_build_diagnostic(msg.message),
|
||||
Message::TextLine(line) => {
|
||||
// Handle the case where we're getting lines directly from rustc.
|
||||
// These are in a different format than the normal cargo output, though I imagine
|
||||
@@ -829,6 +830,11 @@ impl BuildRequest {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle direct rustc diagnostics
|
||||
if let Ok(diag) = serde_json::from_str::<Diagnostic>(&line) {
|
||||
ctx.status_build_diagnostic(diag);
|
||||
}
|
||||
|
||||
// For whatever reason, if there's an error while building, we still receive the TextLine
|
||||
// instead of an "error" message. However, the following messages *also* tend to
|
||||
// be the error message, and don't start with "error:". So we'll check if we've already
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
//! 4. Build fmt layer for non-interactive logging with a custom writer that prevents output during interactive mode.
|
||||
|
||||
use crate::{serve::ServeUpdate, Cli, Commands, Platform as TargetPlatform, Verbosity};
|
||||
use cargo_metadata::{diagnostic::DiagnosticLevel, CompilerMessage};
|
||||
use cargo_metadata::diagnostic::{Diagnostic, DiagnosticLevel};
|
||||
use clap::Parser;
|
||||
use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender};
|
||||
use once_cell::sync::OnceCell;
|
||||
@@ -349,7 +349,7 @@ pub struct TraceMsg {
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TraceContent {
|
||||
Cargo(CompilerMessage),
|
||||
Cargo(Diagnostic),
|
||||
Text(String),
|
||||
}
|
||||
|
||||
@@ -366,9 +366,9 @@ impl TraceMsg {
|
||||
/// Create a new trace message from a cargo compiler message
|
||||
///
|
||||
/// All `cargo` messages are logged at the `TRACE` level since they get *very* noisy during development
|
||||
pub fn cargo(content: CompilerMessage) -> Self {
|
||||
pub fn cargo(content: Diagnostic) -> Self {
|
||||
Self {
|
||||
level: match content.message.level {
|
||||
level: match content.level {
|
||||
DiagnosticLevel::Ice => Level::ERROR,
|
||||
DiagnosticLevel::Error => Level::ERROR,
|
||||
DiagnosticLevel::FailureNote => Level::ERROR,
|
||||
|
||||
@@ -2,6 +2,7 @@ use crate::{
|
||||
serve::{ansi_buffer::AnsiStringLine, ServeUpdate, WebServer},
|
||||
BuildStage, BuilderUpdate, Platform, TraceContent, TraceMsg, TraceSrc,
|
||||
};
|
||||
use cargo_metadata::diagnostic::Diagnostic;
|
||||
use crossterm::{
|
||||
cursor::{Hide, Show},
|
||||
event::{
|
||||
@@ -294,10 +295,10 @@ impl Output {
|
||||
self.pending_logs.push_front(message);
|
||||
}
|
||||
|
||||
pub fn push_cargo_log(&mut self, message: cargo_metadata::CompilerMessage) {
|
||||
pub fn push_cargo_log(&mut self, message: Diagnostic) {
|
||||
use cargo_metadata::diagnostic::DiagnosticLevel;
|
||||
|
||||
if self.trace || !matches!(message.message.level, DiagnosticLevel::Note) {
|
||||
if self.trace || !matches!(message.level, DiagnosticLevel::Note) {
|
||||
self.push_log(TraceMsg::cargo(message));
|
||||
}
|
||||
}
|
||||
@@ -924,7 +925,7 @@ impl Output {
|
||||
use chrono::Timelike;
|
||||
|
||||
let rendered = match log.content {
|
||||
TraceContent::Cargo(msg) => msg.message.rendered.unwrap_or_default(),
|
||||
TraceContent::Cargo(msg) => msg.rendered.unwrap_or_default(),
|
||||
TraceContent::Text(text) => text,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user