Skip to content

Commit

Permalink
fixed log counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Malyugin committed Aug 6, 2018
1 parent 4138c33 commit 18b29a3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
17 changes: 17 additions & 0 deletions com.kuguhome.openhab.prometheusmetrics/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
cd ..
mvn clean
cd com.kuguhome.openhab.prometheusmetrics.p2site/
mvn p2:site
cd ..
mvn install
cd com.kuguhome.openhab.prometheusmetrics/
echo "Copying artifact to Raspberry Pi..."
scp target/*.jar kugu-sz-roman:/usr/share/openhab2/addons
echo "Deploying artifact to Raspberry Pi..."
ssh kugu-sz-roman sudo systemctl restart openhab2
echo "Waiting till application being started..."
sleep 30s
sleep 60s
echo "Fetching Rasberry Pi endpoint $1"
curl $1
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.kuguhome.openhab.prometheusmetrics.internal;

import static org.apache.logging.log4j.Level.*;

import java.util.Dictionary;
import java.util.Hashtable;

Expand All @@ -24,26 +26,23 @@ protected void activate(BundleContext context) {

@Override
public void doAppend(PaxLoggingEvent event) {
switch (event.getLevel().toString()) {
case "TRACE":
TRACE_LABEL.inc();
break;
case "DEBUG":
DEBUG_LABEL.inc();
break;
case "WARN":
WARN_LABEL.inc();
break;
case "ERROR":
ERROR_LABEL.inc();
break;
case "INFO":
INFO_LABEL.inc();
break;
case "FATAL":
FATAL_LABEL.inc();
break;

if (TRACE.name().equals(event.getLevel().toString())) {
TRACE_LABEL.inc();
} else if (DEBUG.name().equals(event.getLevel().toString())) {
DEBUG_LABEL.inc();
} else if (INFO.name().equals(event.getLevel().toString())) {
INFO_LABEL.inc();
} else if (WARN.name().equals(event.getLevel().toString())) {
WARN_LABEL.inc();
} else if (ERROR.name().equals(event.getLevel().toString())) {
ERROR_LABEL.inc();
} else if (FATAL.name().equals(event.getLevel().toString())) {
FATAL_LABEL.inc();
} else {
System.out.println("Level: " + event.getLevel().toString());
}

}

public static final String COUNTER_NAME = "openhab_logmessage_count";
Expand Down

0 comments on commit 18b29a3

Please sign in to comment.