log

ETLUnit 3.9.6

 

Draft in Progress

This document is a draft and is under development.

 

Description

  • Send a message to one or more logs.
  • The message will show up in the test method's log.
  • If a log file name is specified on the log operation, a log file by that name will be created and the message will appear there.

Attributes

List of log() Attributes

 

 

 

message:  - >> TYPE:  string  - - REQUIRED

Both of the following attributes must be present, or neither:

log-file-name:  - >> TYPE:  string 

log-classifier:  - >> TYPE:  string   

Go to top

Individual log() Attributes

message:

  • The message to log.
  • If a log-file-name is provided, the message will be logged there.
  • Otherwise, it will show up indirectly in the test method log.

log-file-name:

  • Unqualified name of the file to log to.
  • SEE example below for an easy way to find this log file and display its contents.
  • Two different log() operations in the same test method will not log to the same physical file.  The second log operation will log to the same log name, but in a different folder.

log-classifier:

  • Used to help identify a log file of interest on the test method report page.

Go to top

Examples

Prerequisites

  • etlunit-core dependency in POM.

 

<dependencies>
	<dependency>
		<groupId>org.bitbucket.bradleysmithllc.etlunit</groupId>
		<artifactId>etlunit-core</artifactId>
		<version>${etlunit.project.version}</version>
	</dependency>
</dependencies>

 

In order to see the report information in the captured images in the following examples, just run the report from the command line after running the test.  The report summary should appear in your default browser.

Go to top

Simplest log() Example

 

Example of simplest log operation

@Test

logWithMessageOnly()

{

log(

message: 'Logging this message by operation log'

);

}

 

This log message doesn't go far, because you did not specify a log file name.  You will, however, find a reference to it in the method log.

 

Go to top

log-file-name and log-classifier must both be present or not present at all

 

@Test

logWithoutLogFileName()

{

// This log operation is missing log-file-name.

log(

message: 'This message will never make it.',

log-classifier: 'anyClassifier'

);

}

 

@Test

logWithoutLogClassifier()

{

// This log operation is missing log-classifier.

log(

message: 'This message will not make it.',

log-file-name: 'log_of_interest.log'

);

}

 

These log messages don't make it into any log.  The log() operation has invalid syntax and cannot be executed.

 

userme > te #logWithoutLog
Processing [2] tests
class experiment.log_operation   -------------------------------------------------
1/2        .logWithoutLogFileName
      ERR_BAD_OPERANDS
  Caused an error                                                             E[1]
2/2        .logWithoutLogClassifier
      ERR_BAD_OPERANDS
  Caused an error                                                             E[2]
Tests run: 2, Errors: 2, Time elapsed: 00.197 sec

 

Go to top

The log() operation using all available attributes

 

@Test

logWithAllAttributes()

{

log(

message: 'Logging with all attributes',

log-file-name: 'log_all_attributes.log',

log-classifier: 'anyClassifier'

);

}

 

When I look at the report summary page for the method, I can find the classifier, and the name of the log that was generated by this log operation.

 


 

If you click on the link for the log, you will see the contents of that log.

 

Go to top

The log() operation will not log to the exact same physical log file twice.

 

Trying to log to the same log twice causes two logs to be created

@Test

logTwiceToSameLog()

{

log(

message: 'Logging Message One with all attributes',

log-file-name: 'log_all_attributes.log',

log-classifier: 'logDemo'

);

 

log(

message: 'Logging Message Two with all attributes',

log-file-name: 'log_all_attributes.log',

log-classifier: 'logDemo'

);

}

 

When you look at the method summary report, there are two different physical log files, not one.

 

The locations of the two log files looks something like this on a Windows system:

  • file:///C:/src/bi-edw-qpt-bucket//target/generated-sources/log/log_operation/logTwiceToSameLog/0_log/log_all_attributes.log
  • file:///C:/src/bi-edw-qpt-bucket//target/generated-sources/log/log_operation/logTwiceToSameLog/1_log/log_all_attributes.log

Close, but not the same log file.

Go to top