public class LogUtil {
public final int DEBUG = 0;
public final int INFO = 1;
public final int ERROR = 2;
public final int NOTHING = 3;
public int level = DEBUG;
public void debug(String msg) {
if (DEBUG >= level) {
System.out.println(msg);
}
}
public void info(String msg) {
if (INFO >= level) {
System.out.println(msg);
}
}
public void error(String msg) {
if (ERROR >= level) {
System.out.println(msg);
}
}
}
new LogUtil().debug("Hello World!");
public class LogUtil {
private static LogUtil logUtilInstance;
public final int DEBUG = 0;
public final int INFO = 1;
public final int ERROR = 2;
public final int NOTHING = 3;
public int level = DEBUG;
private LogUtil() {
}
public static LogUtil getInstance() {
if (logUtilInstance == null) {
logUtilInstance = new LogUtil();
}
return logUtilInstance;
}
public void debug(String msg) {
if (DEBUG >= level) {
System.out.println(msg);
}
}
public void info(String msg) {
if (INFO >= level) {
System.out.println(msg);
}
}
public void error(String msg) {
if (ERROR >= level) {
System.out.println(msg);
}
}
public static void main(String[] args) {
LogUtil.getInstance().debug("Hello World!");
}
}
LogUtil.getInstance().debug("Hello World");
public static LogUtil getInstance() {
if (logUtilInstance == null) {
logUtilInstance = new LogUtil();
}
return logUtilInstance;
}
public synchronized static LogUtil getInstance() {
if (logUtilInstance == null) {
logUtilInstance = new LogUtil();
}
return logUtilInstance;
}
public static LogUtil getInstance() {
if (logUtilInstance == null) {
synchronized (LogUtil.class) {
if (logUtilInstance == null) {
// 这里是必须的,因为有可能两个进程同时执行到synchronized之前
logUtilInstance = new LogUtil();
}
}
}
return logUtilInstance;
}
public class LogUtil {
private static final LogUtil logUtilInstance = new LogUtil();
public final int DEBUG = 0;
public final int INFO = 1;
public final int ERROR = 2;
public final int NOTHING = 3;
public int level = DEBUG;
private LogUtil() {
}
public static LogUtil getInstance() {
return logUtilInstance;
}
public void debug(String msg) {
if (DEBUG >= level) {
System.out.println(msg);
}
}
public void info(String msg) {
if (INFO >= level) {
System.out.println(msg);
}
}
public void error(String msg) {
if (ERROR >= level) {
System.out.println(msg);
}
}
public static void main(String[] args) {
logUtil.getInstance().debug("Hello World!");
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有