LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
analyzer Namespace Reference

Namespaces

namespace  anonymous_namespace{ActorDiscoverer.cpp}
 
namespace  anonymous_namespace{SequenceMessages.cpp}
 
namespace  anonymous_namespace{TestOutline.cpp}
 
namespace  anonymous_namespace{TestRunIndex.cpp}
 

Classes

class  ActorDiscoverer
 
struct  ActorDiscoveryResult
 
struct  ExchangePattern
 Describes how actor-to-actor message flow can be read from the log events. More...
 
struct  FailureGroup
 Failing tests sharing one normalised message. More...
 
struct  SequenceMessage
 One arrow of a sequence diagram: a message from one actor to another. More...
 
struct  TestMarkerRules
 
struct  TestOutline
 
struct  TestRunEntry
 One test of a results folder, read without loading the whole log. More...
 
struct  TestStep
 

Typedefs

using ScanProgress = std::function< bool(std::size_t done, std::size_t total)>
 Called after each scanned log with (done, total); return false to cancel.
 

Enumerations

enum class  ExchangeMode {
  Pair , DirectionField , ReceiverOnly , SenderOnly ,
  PatternField
}
 How actor send/receive relationships are encoded in the log. More...
 
enum class  StepStatus { Passed , Recovered , Failed , NotRun }
 
enum class  TestVerdict { Unknown , Pass , Fail }
 
enum class  FailureSource { None , StepFail , RobotXml }
 Where TestRunEntry::failureMessage came from. More...
 

Functions

static int ScoreAgainst (const std::string &lower, const std::vector< std::string > &words)
 
bool IsPlaceholderActor (std::string_view name)
 
std::vector< std::string > SplitActorList (std::string_view value)
 
std::vector< SequenceMessage > CollectSequenceMessages (db::EventsContainer &events, const ExchangePattern &pattern, std::size_t limit)
 
std::optional< std::int64_t > ParseIsoMicros (std::string_view ts)
 
TestOutline BuildTestOutline (db::EventsContainer &events, const TestMarkerRules &r)
 
TestRunEntry ReadTestLogSummary (const fs::path &file)
 
std::string FindDecisiveFailureMessage (const fs::path &file)
 
std::unordered_map< std::string, std::string > ReadRobotFailures (const fs::path &folder)
 
std::string TestNameKey (std::string_view name)
 
std::string CollapseWhitespace (std::string_view text)
 Collapses whitespace runs (including newlines) to one space and trims.
 
std::string NormalizeFailureMessage (std::string_view message)
 
std::vector< TestRunEntry > ScanResultsFolder (const fs::path &folder, const ScanProgress &progress)
 
std::vector< FailureGroup > GroupFailures (const std::vector< TestRunEntry > &entries)
 
TestRunEntry ReadTestLogSummary (const std::filesystem::path &file)
 
std::string FindDecisiveFailureMessage (const std::filesystem::path &file)
 
std::unordered_map< std::string, std::string > ReadRobotFailures (const std::filesystem::path &folder)
 
std::vector< TestRunEntry > ScanResultsFolder (const std::filesystem::path &folder, const ScanProgress &progress={})
 

Variables

static const std::vector< std::string > kSenderWords
 
static const std::vector< std::string > kReceiverWords
 
static const std::vector< std::string > kActorWords
 
static const std::vector< std::string > kLabelWords
 
static const std::vector< std::string > kOutgoingWords
 
static const std::vector< std::string > kIncomingWords
 
static const std::vector< std::pair< std::string, std::string > > kProtocolPatterns
 
constexpr std::string_view kMetaTestCase = "Test Case"
 File-metadata keys of a safeAPI merged-log header (see SapiLogParser).
 
constexpr std::string_view kMetaStatus = "Status"
 
constexpr std::string_view kMergedLogSuffix = "__merged_logs.txt"
 File-name suffix of a safeAPI merged test log inside a results folder.
 

Typedef Documentation

◆ ScanProgress

using analyzer::ScanProgress = typedef std::function<bool(std::size_t done, std::size_t total)>

Called after each scanned log with (done, total); return false to cancel.

Enumeration Type Documentation

◆ ExchangeMode

enum class analyzer::ExchangeMode
strong

How actor send/receive relationships are encoded in the log.

Enumerator
Pair 

Two distinct fields hold the sender and receiver names. Covers: from+to, source+dest, sender+receiver, client+server, …

DirectionField 

A single actor field plus a direction-value field that distinguishes send from receive. The partner is implied (typically the self actor). Example: component=X, direction=out|in

ReceiverOnly 

Only a receiver field is present; the sender is always the self actor (or unspecified when no self actor is configured). Example: to=B — the log generator is always the one sending

SenderOnly 

Only a sender field is present; the receiver is always the self actor. Example: from=A — the log generator is always the one receiving

PatternField 

Actor names are embedded in a single field using a separator pattern. Example: "RBC: message", "Train T001: info" — extract prefix before ":"

◆ FailureSource

enum class analyzer::FailureSource
strong

Where TestRunEntry::failureMessage came from.

Enumerator
None 

no message found (or the test did not fail)

StepFail 

the decisive STEP_FAIL of the log (see BuildTestOutline)

RobotXml 

xunit.xml <failure message> or output.xml test status text

◆ StepStatus

enum class analyzer::StepStatus
strong
Enumerator
Passed 

ran, no failure recorded

Recovered 

failed at least once, but the failure did not fail the test (retried, or the test passed)

Failed 

failed and was never retried in a failing test

NotRun 

heuristic: logged after the decisive failure without doing anything

◆ TestVerdict

enum class analyzer::TestVerdict
strong
Enumerator
Unknown 
Pass 
Fail 

Function Documentation

◆ BuildTestOutline()

TestOutline analyzer::BuildTestOutline ( db::EventsContainer &  events,
const TestMarkerRules &  rules = {} 
)

Builds the step outline of the first test in events.

  • Sections: "Setup" up to the first TestStep marker, one section per marker, and "Teardown" for the keywords after the last TestExpectation marker (only when that is the last marker). Without TestStep markers everything up to the teardown is one section, "Test".
  • A STEP_FAIL belongs to the latest not-yet-failed STEP of the same keyword. It is recovered when the same keyword with the same arguments starts again later (a retry, e.g. under Wait Until Keyword Succeeds); in a passing test every failure counts as recovered.
  • Verdict: the header Status (file metadata), else (PASS) / (FAIL) in the TEST_END text.
  • Decisive failure (FAIL only): the first STEP_FAIL that is not recovered — the innermost keyword of the failing chain, never a teardown failure that followed it. Without one, TEST_END.
  • Not run (heuristic): after the decisive failure, a section without any command, an expectation, or a keyword that neither failed nor sent a command although the same keyword sent one elsewhere in the log.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CollapseWhitespace()

std::string analyzer::CollapseWhitespace ( std::string_view  text)

Collapses whitespace runs (including newlines) to one space and trims.

Here is the caller graph for this function:

◆ CollectSequenceMessages()

std::vector< SequenceMessage > analyzer::CollectSequenceMessages ( db::EventsContainer &  events,
const ExchangePattern &  pattern,
std::size_t  limit 
)

Collects the actor-to-actor messages of a Pair exchange pattern.

Only events whose sender AND receiver are real actors yield messages: placeholder values ("internal", "none", …) are skipped and multi-actor values are fanned out into one message per receiver/sender. At most limit messages are returned, in event order.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindDecisiveFailureMessage() [1/2]

std::string analyzer::FindDecisiveFailureMessage ( const fs::path &  file)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindDecisiveFailureMessage() [2/2]

std::string analyzer::FindDecisiveFailureMessage ( const std::filesystem::path &  file)

Message of the decisive STEP_FAIL of a failing merged log (empty when the log records none, e.g. a suite-setup failure). Reads every line but parses only the robot marker lines (TEST_START / TEST_END / STEP / STEP_FAIL) and hands them to BuildTestOutline, so the choice matches the Test Steps tab.

◆ GroupFailures()

std::vector< FailureGroup > analyzer::GroupFailures ( const std::vector< TestRunEntry > &  entries)

Groups the FAIL entries that have a message by NormalizeFailureMessage; largest group first, ties in order of first appearance.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsPlaceholderActor()

bool analyzer::IsPlaceholderActor ( std::string_view  name)

True for values that stand in for "no actor" in a sender/receiver field (e.g. destination=internal on events that are local to their source). Case-insensitive. Such values are not actors and never get a lifeline.

Here is the caller graph for this function:

◆ NormalizeFailureMessage()

std::string analyzer::NormalizeFailureMessage ( std::string_view  message)

Grouping signature of a failure message: whitespace collapsed and every run of digits replaced by N, so "not received within 20s" and "not received within 40s" fall into one group.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseIsoMicros()

std::optional< std::int64_t > analyzer::ParseIsoMicros ( std::string_view  ts)

"YYYY-MM-DDTHH:MM:SS[.fraction]…" → µs since the epoch. Any zone suffix is ignored: only differences between timestamps of one log are meaningful.

Here is the caller graph for this function:

◆ ReadRobotFailures() [1/2]

std::unordered_map< std::string, std::string > analyzer::ReadRobotFailures ( const fs::path &  folder)
Here is the caller graph for this function:

◆ ReadRobotFailures() [2/2]

std::unordered_map< std::string, std::string > analyzer::ReadRobotFailures ( const std::filesystem::path &  folder)

Failure messages Robot Framework wrote next to the logs: test name (see TestNameKey) → message. xunit.xml (<testcase name> / <failure message> or <error message>) is used when it exists, else output.xml (the text of a <test>'s own FAIL <status>). Missing or broken files give an empty map.

◆ ReadTestLogSummary() [1/2]

TestRunEntry analyzer::ReadTestLogSummary ( const fs::path &  file)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadTestLogSummary() [2/2]

TestRunEntry analyzer::ReadTestLogSummary ( const std::filesystem::path &  file)

Header and time span of one merged log: reads the # header block, the first event line and the last 64 KiB of the file. Never parses the events.

◆ ScanResultsFolder() [1/2]

std::vector< TestRunEntry > analyzer::ScanResultsFolder ( const fs::path &  folder,
const ScanProgress &  progress 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScanResultsFolder() [2/2]

std::vector< TestRunEntry > analyzer::ScanResultsFolder ( const std::filesystem::path &  folder,
const ScanProgress &  progress = {} 
)

Scans every *__merged_logs.txt of folder (not recursive): ReadTestLogSummary for each, FindDecisiveFailureMessage for FAIL logs only, ReadRobotFailures for FAIL logs still without a message.

The result is in run order: by timestamp (ISO-8601 strings of one run share a time zone, so they compare as text), then by file name. The test that ran before entry i is therefore entry i − 1.

Returns an empty vector when progress cancels.

◆ ScoreAgainst()

static int analyzer::ScoreAgainst ( const std::string &  lower,
const std::vector< std::string > &  words 
)
static
Here is the caller graph for this function:

◆ SplitActorList()

std::vector< std::string > analyzer::SplitActorList ( std::string_view  value)

Splits a sender/receiver value naming several actors ("c-west,c-east") into its trimmed, non-empty parts.

Here is the caller graph for this function:

◆ TestNameKey()

std::string analyzer::TestNameKey ( std::string_view  name)

Matching key for test names: lower-case letters and digits only, so the header name "No Container Is Crash-Looping", the xunit name and the file name "No_Container_Is_Crash-Looping" all match.

Here is the caller graph for this function:

Variable Documentation

◆ kActorWords

const std::vector<std::string> analyzer::kActorWords
static
Initial value:
= {
"actor", "component", "service", "module", "node", "host",
"process", "proc", "peer", "agent", "role", "channel",
"endpoint", "worker", "thread", "pod", "container", "instance"
}

◆ kIncomingWords

const std::vector<std::string> analyzer::kIncomingWords
static
Initial value:
= {
"in", "incoming", "recv", "received", "rx", "receive", "response", "subscribe",
"accept", "processing", "from_request", "inbound", "receiving"
}

◆ kLabelWords

const std::vector<std::string> analyzer::kLabelWords
static
Initial value:
= {
"type", "action", "message", "msg", "command", "cmd",
"request", "response", "event", "method", "operation", "kind",
"function", "procedure", "routine", "handler"
}

◆ kMergedLogSuffix

constexpr std::string_view analyzer::kMergedLogSuffix = "__merged_logs.txt"
inlineconstexpr

File-name suffix of a safeAPI merged test log inside a results folder.

◆ kMetaStatus

constexpr std::string_view analyzer::kMetaStatus = "Status"
inlineconstexpr

◆ kMetaTestCase

constexpr std::string_view analyzer::kMetaTestCase = "Test Case"
inlineconstexpr

File-metadata keys of a safeAPI merged-log header (see SapiLogParser).

◆ kOutgoingWords

const std::vector<std::string> analyzer::kOutgoingWords
static
Initial value:
= {
"out", "outgoing", "send", "sent", "tx", "transmit", "request", "publish",
"initiate", "calling", "request_to", "outbound"
}

◆ kProtocolPatterns

const std::vector<std::pair<std::string, std::string> > analyzer::kProtocolPatterns
static
Initial value:
= {
{"HTTP", "(?:GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\\s+"},
{"gRPC", "\\..*\\."},
{"REST", "/api/"},
{"AMQP", "amqp://"},
{"MQTT", "mqtt://"},
{"TCP", ":\\d+"},
{"Kafka", "topic=|partition="}
}

◆ kReceiverWords

const std::vector<std::string> analyzer::kReceiverWords
static
Initial value:
= {
"to", "dest", "destination", "target", "receiver", "recipient",
"callee", "consumer", "subscriber", "server", "appid", "called_id", "recipient_id"
}

◆ kSenderWords

const std::vector<std::string> analyzer::kSenderWords
static
Initial value:
= {
"from", "sender", "source", "src", "origin", "initiator", "caller",
"producer", "publisher", "client", "ecuid", "caller_id", "originator"
}