package com.wiley.autotest.selenium;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.LoggerFactory;
import org.testng.Reporter;
import ru.yandex.qatools.allure.annotations.Step;

/**
 * Transfers message to necessary end point
 * TestNG
 * Allure
 * Jenkins console
 */
public class Report {
    private String message;

    public Report(String message) {
        this.message = message;
    }

    public Report(String message, Throwable t) {
        this(message + "\n" + ExceptionUtils.getStackTrace(t));
    }

    public void testNG() {
        Reporter.log(message + "<br/>");
    }

    public void allure() {
        allure(message);
    }

    /**
     * hack to send message to allure
     */
    @Step("{0}")
    private void allure(String message) {
    }

    /**
     * Making it an 'error' to guarantee that message will be shown with any log level settings
     */
    public void jenkins() {
        LoggerFactory.getLogger(this.getClass()).error(message);
    }

    public void everywhere() {
        testNG();
        allure();
        jenkins();
    }

}

@@ -120,16 +120,46 @@
 actory;%0A
+import org.slf4j.event.Level;%0A
 import o
@@ -342,16 +342,17 @@
 eport %7B%0A
+%0A
     priv
@@ -370,16 +370,54 @@
 message;
+%0A    private Level level = Level.INFO;
 %0A%0A    pu
@@ -523,488 +523,1045 @@
 ge, 
-Throwable t) %7B%0A        this(message + %22%5Cn%22 + ExceptionUtils.getStackTrace(t));%0A    %7D%0A%0A    public void testNG() %7B%0A        Reporter.log(message + %22%3Cbr/%3E%22);%0A    %7D%0A%0A    public void allure() %7B%0A        allure(message);%0A    %7D%0A%0A    /**%0A     * hack to send message to allure%0A     */%0A    @Step(%22%7B0%7D%22)%0A    private void allure(String message) %7B%0A    %7D%0A%0A    /**%0A     * Making it an 'error' to guarantee that message will be shown with any log level settings%0A
+Level level) %7B%0A        this.message = message;%0A        this.level = level;%0A    %7D%0A%0A    public Report(String message, Throwable t) %7B%0A        this(message + %22%5Cn%22 + ExceptionUtils.getStackTrace(t));%0A    %7D%0A%0A    public Report(String message, Throwable t, Level level) %7B%0A        this(message + %22%5Cn%22 + ExceptionUtils.getStackTrace(t), level);%0A    %7D%0A%0A    public void testNG() %7B%0A        Reporter.log(message + %22%3Cbr/%3E%22);%0A    %7D%0A%0A    public void allure() %7B%0A        allure(message);%0A    %7D%0A%0A    /**%0A     * hack to send message to allure%0A     */%0A    @Step(%22%7B0%7D%22)%0A    private void allure(String message) %7B%0A    %7D%0A%0A    public void jenkins() %7B%0A        switch (level) %7B%0A            case INFO:%0A                LoggerFactory.getLogger(this.getClass()).info(message);%0A                break;%0A            case WARN:%0A                LoggerFactory.getLogger(this.getClass()).warn(message);%0A                break;%0A            case DEBUG:%0A                LoggerFactory.getLogger(this.getClass()).debug(message);%0A   
      
-*/%0A
     
-public void jenkins() %7B%0A
+    break;%0A            case ERROR:%0A        
     
@@ -1613,32 +1613,65 @@
 error(message);%0A
+                break;%0A        %7D%0A
     %7D%0A%0A    publi
@@ -1753,11 +1753,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Set INFO level as default for Report