diff --git a/crates/texrra-tex-core/src/execution/engine/device.rs b/crates/texrra-tex-core/src/execution/engine/device.rs index c4bd161..3d24346 100644 --- a/crates/texrra-tex-core/src/execution/engine/device.rs +++ b/crates/texrra-tex-core/src/execution/engine/device.rs @@ -100,7 +100,7 @@ impl Executor { if let Some(warning) = self.state.glyph_unicode.define(glyph, &value) { let text = format!("native PDF warning: {warning}"); files - .observe_message(&text) + .observe_diagnostic(WriteDestination::TerminalAndLog, &format!("{text}\n")) .map_err(|e| self.error(e, self.current))?; self.events.push(Event::Message { text, @@ -200,7 +200,7 @@ impl Executor { "native PDF warning: object streams require PDF 1.5 or greater; disabled" .to_string(); files - .observe_message(&text) + .observe_diagnostic(WriteDestination::TerminalAndLog, &format!("{text}\n")) .map_err(|e| self.error(e, self.current))?; self.events.push(Event::Message { text, diff --git a/src/native.rs b/src/native.rs index 7093f3e..c43eb29 100644 --- a/src/native.rs +++ b/src/native.rs @@ -33,7 +33,7 @@ use texrra_tex_core::{ execution::{ Cancellation, ExecutionFailure, Executor, FormatImage, InputProfile, JobTime, Limits, NativeSession, RevisionError, RevisionExecution, RevisionFailure, RevisionJob, SourceFile, - SourceProvider, State, + SourceProvider, State, WriteDestination, }, render::DisplayList, resources::{FileWorld, InputSnapshot, ResourceTrace, ResourceVersion, WorldConfig}, @@ -1123,7 +1123,10 @@ impl CompileJob { evidence.diagnostics = export_diagnostics.clone(); notify(&request, revision, CompileStage::Exported, &cancellation)?; for warning in &export_diagnostics { - files.observe_message(&format!("native PDF warning: {warning}"))?; + files.observe_diagnostic( + WriteDestination::TerminalAndLog, + &format!("native PDF warning: {warning}\n"), + )?; } evidence.phase = AttemptPhase::Finishing; let finished = files.finish(); diff --git a/src/native_checkpoint_probe.rs b/src/native_checkpoint_probe.rs index 7b62e3d..01ecd85 100644 --- a/src/native_checkpoint_probe.rs +++ b/src/native_checkpoint_probe.rs @@ -348,7 +348,10 @@ fn original_a3_resume_uses_real_host_and_matches_independent_full_jobs() { .unwrap(); for warning in &pdf.diagnostics { files - .observe_message(&format!("native PDF warning: {warning}")) + .observe_diagnostic( + WriteDestination::TerminalAndLog, + &format!("native PDF warning: {warning}\n"), + ) .unwrap(); } files.finish().unwrap(); diff --git a/tests/native_pdf_links.rs b/tests/native_pdf_links.rs index 66d862e..9c6b861 100644 --- a/tests/native_pdf_links.rs +++ b/tests/native_pdf_links.rs @@ -181,3 +181,33 @@ fn local_structure_action_references_the_shipped_structure_and_later_page() { assert_eq!(destination[1].as_name().unwrap(), b"FitR"); fs::remove_dir_all(root).unwrap(); } + +#[test] +fn each_export_warning_starts_on_its_own_log_line() { + let root = std::env::temp_dir().join(format!("texrra-pdf-warning-lines-{}", std::process::id())); + let source = r"\catcode123=1 \catcode125=2 +\pdfoutput=1 \pdfmajorversion=2 \pdfminorversion=0 +\pdfcompresslevel=0 \pdfobjcompresslevel=0 +\immediate\pdfobj{<< /Type /StructElem /S /Sect >>} +\count1=\pdflastobj +\shipout\hbox{\pdfdest struct \count1 name{first} xyz + \pdfdest struct \count1 name{first} xyz + \pdfdest struct \count1 name{second} xyz + \pdfdest struct \count1 name{second} xyz + \vrule width4pt height3pt} +\message{LAST-MESSAGE} +\end"; + let doc = compile(&root, source, true); + assert_eq!(doc.get_pages().len(), 1); + let transcript = fs::read_to_string(root.join("native/probe.log")).unwrap(); + let descriptions: Vec<_> = transcript + .lines() + .filter_map(|line| line.strip_prefix("native PDF warning: ")) + .collect(); + assert_eq!(descriptions.len(), 2, "{transcript}"); + for (description, target) in descriptions.iter().zip(["first", "second"]) { + assert!(description.contains(&format!("name{{{target}}}"))); + assert!(description.ends_with("duplicate ignored")); + } + fs::remove_dir_all(root).unwrap(); +}