⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.java

📁 j2me sip客户端程序源码 提供了J2ME中SIP协议开发样例源码
💻 JAVA
字号:
/**
 * @(#)$RCSfile: Log.java,v $            $Revision: 1.2 $
 *
 * ====================================================================
 * Copyright 2001, Reaxion Corp.,
 * 11418 105th PL NE, Kirkland, WA, 98033, USA
 * All rights reserved.
 * ====================================================================
 *
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Original Code is the Tequila SyncML.
 *
 * The Initial Developer of the Original Code is Reaxion Corp.
 * All Rights Reserved.
 */
package com.reaxion.tequila.syncml.util;

import java.util.*;
import java.io.*;

/**
 * All debug logs shoud be through this class
 *
 * @version   $1.0$
 * @author    Oleg A. Oksyuk
 */
public class Log
{

    private static long startTime = System.currentTimeMillis();

    private static PrintStream out = System.err;

    public final static int DEBUG_LVL_1 = 1;
    public final static int DEBUG_LVL_2 = 2;
    private static int DEBUG_LEVEL = DEBUG_LVL_2;

    public static void setDebugLevel(int level)
    {
       	DEBUG_LEVEL = level;
    }

/*    public static void setLogFileName(String fileName) throws FileNotFoundException
{
        if (fileName != null)
        {
            out = new PrintStream(new FileOutputStream(fileName));
        }
        else
        {
            out = System.err;
        }
    }
*/
    public static void println()
    {
      	out.print("\r\n");
   	}
    public static void printEx(Throwable ex)
    {
       	ex.printStackTrace();
   	}
    public static void println(Object msg)
    {
       	println(msg, DEBUG_LVL_1);
   	}
    public static void println(Object msg, int debugLevel)
    {
        print(msg+"\r\n", debugLevel);
    }
    public static void print(Object msg)
    {
       	print(msg, DEBUG_LVL_1);
   	}
    public static void print(Object msg, int debugLevel)
    {
        if (DEBUG_LEVEL < debugLevel)
        {
            return;
        }
        long time = System.currentTimeMillis()-startTime;
        String timeStr = String.valueOf(time);
        int addCnt = 6-timeStr.length(), i;
        for (i=0;i<addCnt;i++)
        {
           	timeStr="0"+timeStr;
        }
        int len=timeStr.length();
        timeStr=timeStr.substring(0, len-3)+"."+timeStr.substring(len-3);
        out.print(timeStr+"    "+msg);
        out.flush();
    }
}

/* -----------------------------------------------------------------------------
 * Change log:
 * -----------------------------------------------------------------------------
 * $Log: Log.java,v $
 * Revision 1.2  2001/10/17 15:27:41  OlegO
 * changed comments for better javadoc
 *
 * Revision 1.1.1.1  2001/10/11 13:13:32  OlegO
 * no message
 *
 * Revision 1.1  2001/07/24 13:08:18  OlegO
 * no message
 *
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -