Skip to content

Commit

Permalink
tests(gorgone): use gorgone log format to fix automated tests
Browse files Browse the repository at this point in the history
Refs:MON-106121
  • Loading branch information
Evan-Adam committed Nov 26, 2024
1 parent 6afc638 commit 0bb4f11
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gorgone/tests/robot/resources/LogResearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def ctn_find_in_log(log: str, date, content, regex=False):


def ctn_extract_date_from_log(line: str):
p = re.compile(r"^\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\]")
p = re.compile(r"^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})")
m = p.match(line)
if m is None:
return None
Expand Down
2 changes: 1 addition & 1 deletion gorgone/tests/robot/resources/resources.resource
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Wait Until Port Is Bind

Ctn Check No Error In Logs
[Arguments] ${gorgone_id}
${cmd}= Set Variable grep -vP '^\\[\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\] ' /var/log/centreon-gorgone/${gorgone_id}/gorgoned.log
${cmd}= Set Variable grep -vP '^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2} ' /var/log/centreon-gorgone/${gorgone_id}/gorgoned.log
Log To Console \n\n${cmd}\n\n

${log_line_wrong} RUN ${cmd}
Expand Down
10 changes: 6 additions & 4 deletions perl-libs/lib/centreon/common/logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,14 @@ sub writeLog($$$%) {

# do nothing if the configured severity does not imply logging this message
return if ($self->{severity} < $severity);
if (length($msg) > 20000) {
$msg = substr($msg, 0, 20000) . '...';
}
$msg = ($self->withpid()) ? "$$ - $msg" : $msg;

$msg = ($self->withpid()) ? "[$$] $msg" : $msg;

my $datedmsg = "[" . $human_severities{$severity} . "] " . $msg . "\n";
my $datedmsg = $human_severities{$severity} . " - " . $msg . "\n";
if ($self->withdate()) {
$datedmsg = "[" . $self->get_date . "] " . $datedmsg;
$datedmsg = $self->get_date . " - " . $datedmsg;
}
if ($self->{log_mode} == 1 and defined($self->{filehandler})) {
print {$self->{filehandler}} $datedmsg;
Expand Down

0 comments on commit 0bb4f11

Please sign in to comment.