Adding a port forwarder logger, Example – Nortel Networks NN46120-104 User Manual

Page 279

Advertising
background image

Example

279

Adding a Port Forwarder Logger

A Port Forwarder logger must implement the PortForwarderLogger
interface:

public void log(int logLevel, int logCode, Object[] params, Throwable

throwable);

public void log(int logLevel, String msg, Throwable throwable);

The first function is used when the Port Forwarder logs a message
in the Messages.properties file, i.e. messages of type PortForwar
derConstants.LOG_LEVEL_INFO and PortForwarderConstants.L
OG_LEVEL_ERROR and the second one is used for messages
of type PortForwarderConstants.LOG_LEVEL_DEBUG and
PortForwarderConstants.LOG_LEVEL_DEBUG_VERBOSE.

The PortForwarderLogger is added to the Port Forwarder by calling the
setLogger function.

Example

Following is an example of the code for adding a Port Forwarder logger.

public class PortForwarderLoggerImpl implements PortForwarderLogger {

private final ResourceBundle messages;

private PortForwarderGui portForwarderGui;

/**

* Creates a new instance of PortForwarderLoggerImpl

*/

public PortForwarderLoggerImpl() {

messages = ResourceBundle.getBundle("Messages");

}

/**

* Tells the logger in which gui to log messages.

*

* @param portForwarderGui The gui to use

*/

public void setGui(PortForwarderGui portForwarderGui) {

this.portForwarderGui = portForwarderGui;

}

private String createTimeStamp() {

SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss.SSS

");

String timeStamp = dateFormat.format(new Date());

return timeStamp;

}

private String createMessage(String msg) {

return createTimeStamp() + " : " + msg;

}

Nortel VPN Gateway

User Guide

NN46120-104

02.01

Standard

14 April 2008

Copyright © 2007-2008 Nortel Networks

.

Advertising