mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-12 22:56:34 +00:00
fhem.pl: escapeLogLine from Boris, forum#21232
git-svn-id: https://svn.fhem.de/fhem/trunk@5185 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
98d5384eef
commit
b82bda871f
25
fhem/fhem.pl
25
fhem/fhem.pl
@ -90,6 +90,7 @@ sub fhz($);
|
||||
sub getAllGets($);
|
||||
sub getAllSets($);
|
||||
sub latin1ToUtf8($);
|
||||
sub escapeLogLine($);
|
||||
sub readingsBeginUpdate($);
|
||||
sub readingsBulkUpdate($$$@);
|
||||
sub readingsEndUpdate($$);
|
||||
@ -3148,6 +3149,13 @@ ReadingsVal($$$)
|
||||
return $default;
|
||||
}
|
||||
|
||||
sub
|
||||
ReadingsNum($$$)
|
||||
{
|
||||
my ($d,$n,$default) = @_;
|
||||
return ReadingsVal($d,$n,$default)+0;
|
||||
}
|
||||
|
||||
sub
|
||||
ReadingsTimestamp($$$)
|
||||
{
|
||||
@ -3691,6 +3699,23 @@ utf8ToLatin1($)
|
||||
return $s;
|
||||
}
|
||||
|
||||
# replaces some common control chars by escape sequences
|
||||
# in order to make logs more readable
|
||||
sub escapeLogLine($) {
|
||||
my ($s)= @_;
|
||||
|
||||
my %escSequences = (
|
||||
'\t' => "\\t",
|
||||
'\n' => "\\n",
|
||||
'\r' => "\\r",
|
||||
);
|
||||
|
||||
foreach my $regex (keys %escSequences) {
|
||||
$s =~ s/$regex/$escSequences{$regex}/g;
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
sub
|
||||
Debug($) {
|
||||
my $msg= shift;
|
||||
|
Loading…
x
Reference in New Issue
Block a user