How to shorten the result of LogReader?

Hello, everybody!:grinning:

I have found a good solution to see the error or warning provided by LogReader.

First my sitemap and items

	Frame label="Sistema" {
		Text item=logreaderErrors
		Text item=logreaderWarnings
		Text item=logreaderLastError
		Text item=logreaderLastWarning
		Text item=logreaderLastErrorFixed
		Text item=logreaderLastWarningFixed
	}
Number   logreaderErrors            "Errores encontrados [%d]"                     <alarmerror> { channel="logreader:reader:openhablog:errorEvents" }
String   logreaderLastError         "Last error [%s]"                                       { channel="logreader:reader:openhablog:lastErrorEvent" }
Number   logreaderWarnings          "Advertencias encontradas [%d]"                   <alarmwarning> { channel="logreader:reader:openhablog:warningEvents" }
String   logreaderLastWarning       "Last warning [%s]"                                     { channel="logreader:reader:openhablog:lastWarningEvent" }
String   logreaderLastWarningFixed  "Last warning Fix [%s]"
String   logreaderLastErrorFixed  "Last error Fix [%s]"

Now, we created the following rules to remove the date, time, type of message (error or warning), and the following bracketed text

rule "WARN FIX"
    when
        Item logreaderLastWarning changed
    then
        val textwarning = transform("REGEX", ".*] - (.+)", logreaderLastWarning.state.toString)
    logreaderLastWarningFixed.postUpdate( textwarning )
end

rule "ERRO FIX"
    when
        Item logreaderLastError changed
    then
        val texterror = transform("REGEX", ".*] - (.+)", logreaderLastError.state.toString)
    logreaderLastErrorFixed.postUpdate( texterror )
end

And the results:

Real case:

3

And that’s it. It may not be the final solution to the problem of long text but at least it allows you to see where the problem is with better definition than before.

Greetings!

6 Likes