本站不再更新,歡迎光臨 java開發技術網
          隨筆-230  評論-230  文章-8  trackbacks-0

          package com.ff.utils;

          import java.util.Date;

          import net.rim.device.api.system.EventLogger;

          /**
           * 日志類
           * @author   2010-09-04
           *
           */
          public class Logger {

           private static final String SEPARATOR = "   ";
           private static final long GUID = 0x4c9d3452d880a2f1L;
           private static final String APP_NAME = "xxxc ";

           private Logger() {
            EventLogger.register(GUID, APP_NAME, EventLogger.VIEWER_STRING);
           }

           private static Logger logger = new Logger();

           public static Logger getLogger() {
            return logger;
           }

           /**
            * Log the information.
            *
            * @param message
            *            The message you will log
            */
           public void info(String message) {
            if (message == null || message.trim().equals(""))
             return;
            String log = "INFO: " + new Date().toString() + SEPARATOR + message;
            try {
             log = new String(log.getBytes(), "UTF-8");
             byte[] msg_bytes = log.getBytes();
             EventLogger.logEvent(GUID, msg_bytes, EventLogger.ALWAYS_LOG);
            } catch (Exception ex) {
             System.err.println(ex);
            }
           }

           public void error(Exception e) {
            StringBuffer log = new StringBuffer();
            log.append("ERROR: " + new Date().toString() + SEPARATOR);
            log.append(e.getMessage() + " \r\n ");

            try {
             byte[] msg_bytes = new String(log.toString().getBytes(), "UTF-8").getBytes();
             EventLogger.logEvent(GUID, msg_bytes);
            } catch (Exception ex) {
             System.err.println(ex);
            }
           }
           
           public void error(String message, Exception e) {
            StringBuffer log = new StringBuffer();
            log.append("ERROR: " + new Date().toString() + SEPARATOR);
            if (message != null || !message.trim().equals("")) {
             log.append("message: " + message + " \r\n ");
            }
            log.append("error: " + e.getMessage() + " \r\n ");

            try {
             byte[] msg_bytes = new String(log.toString().getBytes(), "UTF-8").getBytes();
             EventLogger.logEvent(GUID, msg_bytes);
            } catch (Exception ex) {
             System.err.println(ex);
            }
           }
          }


          不管是在模擬器還是真機,日志還是必須的......如果該文對你有用,為了表示對作者的支持,麻煩你單擊一下下面的廣告,謝謝

          posted on 2010-09-05 16:55 有貓相伴的日子 閱讀(602) 評論(0)  編輯  收藏 所屬分類: blackberry

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          本站不再更新,歡迎光臨 java開發技術網
          主站蜘蛛池模板: 德兴市| 庄浪县| 天峨县| 东乌珠穆沁旗| 太湖县| 梅河口市| 独山县| 房产| 荥阳市| 大名县| 涡阳县| 三亚市| 南宁市| 石屏县| 林芝县| 泾阳县| 嘉黎县| 洛川县| 通城县| 临桂县| 沛县| 农安县| 榆社县| 平利县| 凤凰县| 武穴市| 无极县| 大姚县| 揭西县| 阿拉善盟| 汉中市| 淳安县| 比如县| 神池县| 昭平县| 西贡区| 平顺县| 南宁市| 新兴县| 马尔康县| 东乌珠穆沁旗|