package com.onaro.sanscreen.client.log; import java.text.MessageFormat; import java.util.ResourceBundle; import com.netapp.oci.platform.common.audit.interfaces.data.AuditComponent; import com.onaro.sanscreen.client.ejb.SessionsManager; import com.onaro.sanscreen.server.audit.interfaces.remote.AuditRemote; /** * This class supports logging messages to the audit log. Use enum to enforce Singleton pattern. * * @author rnoel * */ public enum ClientAuditLog { INSTANCE; private static final ResourceBundle MESSAGES = ResourceBundle.getBundle("com.onaro.sanscreen.client.log.Messages"); //$NON-NLS-1$ /** * Adds a message to the server's audit log. * * @param messageId the ID from the properties file for the message to display. This is the root key. We look for a * messageId.action for the action string to use as the audit type, and messageId.details for the message string. * @param args the arguments to use to format into the message. */ public void log(String messageId, Object...args) { AuditRemote auditRemote = SessionsManager.getInstance().getSession(AuditRemote.class); String pattern = MESSAGES.getString(messageId + ".details"); //$NON-NLS-1$ String message = MessageFormat.format(pattern, args); String action = MESSAGES.getString(messageId + ".action"); //$NON-NLS-1$ System.out.println("ClientAuditLog.log action: '" + action + "' message: '" + message + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ auditRemote.log(AuditComponent.CLIENT, action, message); } }