Improve logging to telegram

This commit is contained in:
2023-04-10 19:18:43 +02:00
parent 4c3f18f852
commit 4a024c4476
5 changed files with 74 additions and 50 deletions

View File

@@ -21,8 +21,9 @@ pipeline {
}
String output = readFile 'log.txt'
if(output != "") {
output = clean(output)
output.split('\n').each {
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
outputList = clean(outputList)
outputList.each {
telegramSendManual(it)
}
}
@@ -48,14 +49,19 @@ pipeline {
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91.App - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91.App - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
private ArrayList<String> clean(ArrayList<String> orig) {
ArrayList<String> cleaned = new ArrayList<String>()
orig.each{line ->
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
line = line.substring(20, line.size())
}
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
line = line.substring(20, line.size())
}
cleaned.add(line)
}
return orig
return cleaned.unique()
}
def telegramSendManual(String text) {

View File

@@ -42,8 +42,9 @@ pipeline {
}
}
if(errorOutput != "") {
errorOutput = clean(errorOutput)
errorOutput.split('\n').toList().unique().each {
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
outputList = clean(outputList)
outputList.each {
telegramSendManual(it)
}
}
@@ -65,14 +66,19 @@ pipeline {
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91.App - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91.App - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
private ArrayList<String> clean(ArrayList<String> orig) {
ArrayList<String> cleaned = new ArrayList<String>()
orig.each{line ->
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
line = line.substring(20, line.size())
}
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
line = line.substring(20, line.size())
}
cleaned.add(line)
}
return orig
return cleaned.unique()
}
def telegramSendManual(String text) {

View File

@@ -24,10 +24,11 @@ pipeline {
} catch (Exception e) {
telegramSendManual("TLW-Database-Tool crashed!")
}
String output = readFile 'log.txt'
if(output != "") {
output = clean(output)
output.split('\n').toList().unique().each {
String outputString = readFile 'log.txt'
if(outputString != "") {
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
outputList = clean(outputList)
outputList.each {
telegramSendManual(it)
}
}
@@ -47,14 +48,19 @@ pipeline {
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91.App - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91.App - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
private ArrayList<String> clean(ArrayList<String> orig) {
ArrayList<String> cleaned = new ArrayList<String>()
orig.each{line ->
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
line = line.substring(20, line.size())
}
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
line = line.substring(20, line.size())
}
cleaned.add(line)
}
return orig
return cleaned.unique()
}
def telegramSendManual(String text) {

View File

@@ -42,8 +42,9 @@ pipeline {
}
}
if(errorOutput != "") {
errorOutput = clean(errorOutput)
errorOutput.split('\n').toList().unique().each {
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
outputList = clean(outputList)
outputList.each {
telegramSendManual(it)
}
}
@@ -65,19 +66,19 @@ pipeline {
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91 - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91 - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
private ArrayList<String> clean(ArrayList<String> orig) {
ArrayList<String> cleaned = new ArrayList<String>()
orig.each{line ->
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
line = line.substring(20, line.size())
}
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
line = line.substring(20, line.size())
}
cleaned.add(line)
}
while(orig.indexOf(" [main] ERROR de.jeyp91 - ") > 0) {
int index = orig.indexOf(" [main] ERROR de.jeyp91 - ")
String newString = orig.substring(0, index-12) + orig.substring(index+31, orig.size())
orig = newString
}
return orig
return cleaned.unique()
}
def telegramSendManual(String text) {

View File

@@ -41,14 +41,19 @@ pipeline {
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91.App - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91.App - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
private ArrayList<String> clean(ArrayList<String> orig) {
ArrayList<String> cleaned = new ArrayList<String>()
orig.each{line ->
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
line = line.substring(20, line.size())
}
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
line = line.substring(20, line.size())
}
cleaned.add(line)
}
return orig
return cleaned.unique()
}
def telegramSendManual(String text) {