All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xnx3.Log Maven / Gradle / Ivy

The newest version!
package com.xnx3;

/**
 * 日志输出调试
 * @author 管雷鸣
 *
 */
public class Log {
	public static boolean debug = true;	//默认为true,开启
	public static boolean error = true;	//默认为true,开启
	public static boolean info = true;	//默认为true,开启

	/**
	 * 增加一条错误的log信息
	 */
	public static void debug(String text){
		if(debug){
			StackTraceElement st = Thread.currentThread().getStackTrace()[2];
			System.out.println(text+" \t "+st.getClassName()+"."+st.getMethodName()+"() "+st.getLineNumber()+" Line");
		}
	}
	
	public static void error(String text){
		if(error){
			StackTraceElement st = Thread.currentThread().getStackTrace()[2];
			System.err.println(text+" \t "+st.getClassName()+"."+st.getMethodName()+"() "+st.getLineNumber()+" Line");
		}
	}
	
	public static void main(String[] args) {
		debug = true;
		debug("测试一下");
	}
	
	public static void log(String text){
		StackTraceElement st = Thread.currentThread().getStackTrace()[2];
		System.out.println(text+" \t "+st.getClassName()+"."+st.getMethodName()+"() "+st.getLineNumber()+" Line");
	}
	public static void info(String text){
		if(info){
			StackTraceElement st = Thread.currentThread().getStackTrace()[2];
			System.out.println(text+" \t "+st.getClassName()+"."+st.getMethodName()+"() "+st.getLineNumber()+" Line");
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy