Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions rust/agama-utils/src/api/question.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::gettext_noop;
use gettextrs::gettext;
use merge::Merge;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::{collections::HashMap, fmt};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down Expand Up @@ -105,7 +105,7 @@ impl AnswerRule {
}

/// Represents a question including its [specification](QuestionSpec) and [answer](QuestionAnswer).
#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)]
#[derive(Clone, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Question {
/// Question ID.
Expand All @@ -118,6 +118,16 @@ pub struct Question {
pub answer: Option<Answer>,
}

impl fmt::Debug for Question {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Question")
.field("id", &self.id)
.field("spec", &self.spec)
.field("answer", &self.answer.as_ref().map(|_| "[FILTERED]"))
.finish()
}
}

impl Question {
/// Creates a new question using the given ID and spec.
///
Expand Down
3 changes: 3 additions & 0 deletions rust/agama-utils/src/question/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@ impl MessageHandler<message::Ask> for Service {
if let Some(answer) = self.find_answer(&question.spec) {
_ = question.set_answer(answer);
}
tracing::info!("Asking question: {:?}", question);
self.questions.push(question.clone());

self.events.send(Event::QuestionAdded {
id: self.current_id,
})?;

if question.answer.is_some() {
tracing::info!("Question {} answered", question.id);
self.events.send(Event::QuestionAnswered {
id: self.current_id,
})?;
Expand All @@ -147,6 +149,7 @@ impl MessageHandler<message::Answer> for Service {
match found {
Some(question) => {
question.set_answer(message.answer)?;
tracing::info!("Question {} answered", question.id);
self.events
.send(Event::QuestionAnswered { id: message.id })?;
Ok(())
Expand Down
6 changes: 6 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Feb 19 16:42:12 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Add logging about questions to make debugging easier
(gh#agama-project/agama#3190).

-------------------------------------------------------------------
Thu Feb 19 13:35:59 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
Loading