This form avoids superfluous object creation when the logger is disabled for the TRACE level.
104105106107108109110111112113114
// Get the start of the current period final Time startOfPeriod = Time.now(); if (log.isTraceEnabled()) { log.trace("Run the job: '{}'", code); } try { // Run the user's code
120121122123124125126127128129130
"Unhandled exception thrown by user code in task " + name, e); } if (log.isTraceEnabled()) { log.trace("Finished with job: '{}'", code); } // Sleep until the period is over (or not at all if it's // already passed) startOfPeriod.add(frequency).fromNow().sleep();
100101102103104105106107108109110
// Get the start of the current period final Time startOfPeriod = Time.now(); if (log.isTraceEnabled()) { log.trace("Run the job: " + code.toString()); } try { // Run the user's code
115116117118119120121122123124125
log.error("Unhandled exception thrown by user code in task " + name, e); } if (log.isTraceEnabled()) { log.trace("Finished with job: " + code.toString()); } // Sleep until the period is over (or not at all if it's // already passed) startOfPeriod.add(frequency).fromNow().sleep();
6768697071727374757677
} catch (Exception e) { logger.debug(e.getMessage()); logger.debug(Utils.getStackTrace(e)); } logger.trace( "Request packet sent to: {} Interface: {}", broadcast.getHostAddress(), networkInterface.getDisplayName()); } } logger.trace( "Done looping over all network interfaces. Now waiting for a reply!"); bcSend.close();
7172737475767778798081
logger.trace( "Request packet sent to: {} Interface: {}", broadcast.getHostAddress(), networkInterface.getDisplayName()); } } logger.trace( "Done looping over all network interfaces. Now waiting for a reply!"); bcSend.close(); DatagramSocket bcReceipt = new DatagramSocket(23272); bcReceipt.setReuseAddress(true);
8384858687888990919293
byte[] recvBuf = new byte[15000]; DatagramPacket receivePacket = new DatagramPacket(recvBuf, recvBuf.length); bcReceipt.receive(receivePacket); //We have a response logger.trace( "Broadcast response from server: {}", receivePacket.getAddress()); //Check if the message is correct String message = new String(receivePacket.getData()).trim(); if (message.startsWith("eQ3Max")) {
96979899100101102103104105106
maxCubeName=message.substring(0, 8); rfAddress=message.substring(8, 18); logger.debug("Found at: {}", maxCubeIP); logger.debug("Name : {}", maxCubeName); logger.debug("Serial : {}", rfAddress); logger.trace("Message : {}", message); } else { logger.info("No Max!Cube gateway found on network"); } //Close the port!
9899100101102103104105106107108
public void testTrace() { Logger mock = createStrictMock(Logger.class); expect(mock.getName()).andReturn("foo"); mock.trace("a"); replay(mock); InternalLogger logger = new Slf4JLogger(mock); logger.trace("a"); verify(mock);
112113114115116117118119120121122
public void testTraceWithException() { Logger mock = createStrictMock(Logger.class); expect(mock.getName()).andReturn("foo"); mock.trace("a", e); replay(mock); InternalLogger logger = new Slf4JLogger(mock); logger.trace("a", e); verify(mock);