Package com.avoka.tm.util
Class Logger
java.lang.Object
com.avoka.tm.util.Logger
- All Implemented Interfaces:
- com.avoka.core.groovy.runtime.IBindable
Provides a Logger class for logging information during the execution of Groovy scripts. A logger instance will be injected into groovy script object before it is invoked. To use the Logger a groovy script class must provide a public Logger field with the name logger.
Service Example
The Groovy class below example below declares a public Logger variable with is used for logging.
 import com.avoka.tm.util.*
 import com.avoka.tm.vo.*
 import jakarta.servlet.http.*
 class FluentGroovyService {
     // Injected at runtime
     public Logger logger
     Object invoke(SvcDef svcDef, HttpServletRequest request, User user, Map params) {
         logger.info 'groovy result - ' + params.formId
         return null
     }
 } 
 Unit Test Example
 When using a Logger in a JUnitTest you must specify that the logger field is static otherwise a NPE will occur.
 This is because the JUnitTest runner will clone the unit test object when executing separate unit test methods
 to ensure their state is well isolated from other unit test methods.
 
 import com.avoka.tm.svc.*
 import com.avoka.tm.test.*
 import com.avoka.tm.util.*
 import com.avoka.tm.vo.*
 import org.junit.*
 class UnitTest extends AbstractJUnitTest {
     // Injected at runtime
     public static Logger logger
     // Perform service unit test
     @Test
     void test() throws Exception {
         Map args = [
             "formId": 23
         ]
         Map params = [
             "svcDef": svcDef,
             "request": null,
             "user": null,
             "params": args
         ]
         def result = new ServiceInvoker(svcDef).invoke(params)
         // Check result
         logger.info params
         assert "groovy result - 23" == result
     }
 } - Since:
- 17.10.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidLog the given DEBUG level message.voidLog the given DEBUG level message.voidLog the given ERROR level message.voidLog the given ERROR level message.voidLog the given INFO level message.voidLog the given INFO level message.voidLog the given WARN level message.voidLog the given WARN level message.
- 
Constructor Details- 
Loggerpublic Logger()Create a logger instance.
- 
Loggerpublic Logger(boolean standalone) Create a logger instance.- Parameters:
- standalone- log message to console.
 
 
- 
- 
Method Details- 
debugLog the given DEBUG level message.- Parameters:
- object- the DEBUG level message
 
- 
debugLog the given DEBUG level message.- Parameters:
- object- the DEBUG level message
 
- 
errorLog the given ERROR level message.- Parameters:
- object- the ERROR level message
 
- 
errorLog the given ERROR level message.- Parameters:
- object- the ERROR level message
 
- 
infoLog the given INFO level message.- Parameters:
- object- the INFO level message
 
- 
infoLog the given INFO level message.- Parameters:
- object- the INFO level message
 
- 
warnLog the given WARN level message.- Parameters:
- object- the WARN level message
 
- 
warnLog the given WARN level message.- Parameters:
- object- the WARN level message
 
- 
getBindingName- Specified by:
- getBindingNamein interface- com.avoka.core.groovy.runtime.IBindable
- Returns:
- the binding name "logger".
- See Also:
- 
- IBindable.getBindingName()
 
 
- 
getBindingType- Specified by:
- getBindingTypein interface- com.avoka.core.groovy.runtime.IBindable
- Returns:
- the binding type ElementType.FIELD
- See Also:
- 
- IBindable.getBindingType()
 
 
- 
getDebugLevelLogBuilder- Returns:
- the logger instance debug level log builder, or null if not used
 
- 
getInfoLevelLogBuilder- Returns:
- the logger instance info level log builder, or null if not used
 
 
-