package ums.caf.common.log; import java.net.*; import ums.uep.api.*; import ums.uep.api.pfl.finterface.*; import ums.uep.api.pfl.log.*; /** * <p>Title: CAF日志接口</p> * <p>Description: CAF分装接口,只需要应用填写如下内容:</p> * <p>操作日志:LOGMODE[日志模式];Rank[级别];Command[命令码];Command Function[命令功能];isSuccess[是否成功];failInfo[失败原因];Detailed Information[详细信息]。</p> * <p>系统日志:Rank[级别]; Source [来源];Log Name [日志名称];Detailed Information[详细信息]。 </p> * <p>Copyright: 2005</p> * <p>Company: ZTE-CDMA</p> * @author hejw * @version 1.0 */ public class ClientLog { /** * 系统日志级别 INFORM */ public static final short SYSLOG_INFORM = 6; /** * 系统日志级别 NOTICE */ public static final short SYSLOG_NOTICE = 5; /** * 系统日志级别 WARN */ public static final short SYSLOG_WARN = 4; /** * 系统日志级别 ERROR */ public static final short SYSLOG_ERROR = 3; /** * 系统日志级别 ALTERT */ public static final short SYSLOG_ALTERT = 2; /** * 系统日志级别 EMERG */ public static final short SYSLOG_EMERG = 1; /** * 操作日志级别 NORMAL */ public static final short CMDLOG_NORMAL = 4; /** * 操作日志级别 NOTICE */ public static final short CMDLOG_NOTICE = 3; /** * 操作日志级别 IMPORTANT */ public static final short CMDLOG_IMPORTANT = 2; /** * 操作日志级别 VERYIMPORTANT */ public static final short CMDLOG_VERYIMPORTANT = 1; /** * 记录日志模式 GUI */ public static final short LOGMODE_GUI = 0; //"GUI"; /** * 记录日志模式 TELNET */ public static final short LOGMODE_TELNET = 1; // "TELNET"; /** * 记录日志模式 CLI */ public static final short LOGMODE_CLI = 2; //"CLI"; /** * 记录日志模式 CORBA */ public static final short LOGMODE_CORBA = 3; //"CORBA"; /** * 记录日志模式 WEB */ public static final short LOGMODE_WEB = 4; //"WEB"; /** * 记录日志模式 SNMP */ public static final short LOGMODE_SNMP = 5; //"SNMP"; // private static String COMMAND = "CDMA_COMMAND"; //不需要命令码 private static String localHost = null; private static LogClientService logClientService = ServiceAccess. getLogClientService(); private static FClientService fs = ServiceAccess.getFClientService(); public ClientLog() { } /** * 记录操作日志接口 * @param logmode 记录日志模式 * @param rank 日志级别 * @param command 命令码 * @param cmdFunction 命令功能 * @param isSuccess 成功表示 * @param failInfo 失败原因 * @param detailInfo 详细信息 */ public static void insertCmdLog(short logmode, short rank, int command,String cmdFunction, boolean isSuccess, String failInfo, String detailInfo) { String mode; switch (logmode) { case 0: mode = "GUI"; break; case 1: mode = "TELNET"; break; // case 2: // mode = "CLI"; // break; case 2: mode = "TELNET"; break; case 3: mode = "CORBA"; break; case 4: mode = "WEB"; break; case 5: mode = "SNMP"; break; default: mode = "GUI"; } java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis()); String userName = fs.getUserName(); logClientService.insertCmdLog(userName != null ? userName : "CDMA", String.valueOf(command), //不需要命令码 cmdFunction, detailInfo, failInfo, isSuccess == true ? 0 : 1, getLocalHostAddress(), //客户端ip mode, //接入方式 null, //操作对象类型,可填null, null, //操作对象id,可填null now, //操作发起时间 now, //操作开始 now, //结束时间 0, //关联日志id,没有关联的则填LogServerService.LOG_NO_RELATE_ID rank, //级别,必填, 1, //显示过滤,必填, null); } /** * 记录日志 * @param userName 用户名 * @param logmode 记录日志模式 * @param rank 日志级别 * @param command 命令码 * @param cmdFunction 命令功能 * @param isSuccess 成功表示 * @param failInfo 失败原因 * @param detailInfo 详细信息 */ public static void insertCmdLog(String userName,short logmode, short rank, int command, String cmdFunction, boolean isSuccess, String failInfo, String detailInfo) { String mode; switch (logmode) { case 0: mode = "GUI"; break; case 1: mode = "TELNET"; break; // case 2: // mode = "CLI"; // break; case 2: mode = "TELNET"; break; case 3: mode = "CORBA"; break; case 4: mode = "WEB"; break; case 5: mode = "SNMP"; break; default: mode = "GUI"; } java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis()); logClientService.insertCmdLog( userName, String.valueOf(command), //不需要命令码 cmdFunction, detailInfo, failInfo, isSuccess ? LogServerService.CSF_LOG_OPERATER_SUCCESS : LogServerService.CSF_LOG_OPERATER_ERROR, getLocalHostAddress(), mode, null, null, now, now, now, 0, rank, LogServerService.LOG_DISPLAY_NOTFILETER, null); } /** * 记录系统日志接口 * @param sysRank 日志级别 * @param sysSource 日志来源 * @param syslogName 日志名称 * @param logDetailInfo 详细信息 */ public static void insertSysLog(short sysRank, String sysSource, String syslogName, String logDetailInfo) { java.sql.Timestamp now = new java.sql.Timestamp(System.currentTimeMillis()); logClientService.insertSysLog(sysRank, sysSource, syslogName, logDetailInfo, getLocalHostAddress(), now, now, 1, //显示过滤 null); } private static String getLocalHostAddress() { try { if (localHost == null) { localHost = InetAddress.getLocalHost().getHostAddress(); return localHost; } else { return localHost; } } catch (Exception ex) { return ""; } } }