com.ait.toolkit.node.dev.debug.DebugLog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ahome-node Show documentation
Show all versions of ahome-node Show documentation
Ahome-Node - A GWT toolkit for node.js and nw.js.
The newest version!
/*
Copyright (c) 2014 Ahomé Innovation Technologies. All rights reserved.
Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.ait.toolkit.node.dev.debug;
import com.ait.toolkit.node.core.node.stream.WritableStream;
import com.ait.toolkit.node.core.node.util.Util;
/**
* Simple log implementation for the OOPHM debugger
*
*
*/
public class DebugLog {
private final static Util util = Util.get();
private final WritableStream out;
private final Level lowestLevel;
public DebugLog(WritableStream out, Level lowestLevel) {
this.out = out;
this.lowestLevel = lowestLevel;
}
public Level getLowestLevel() {
return lowestLevel;
}
public boolean isDebugEnabled() {
return lowestLevel.ordinal() <= Level.DEBUG.ordinal();
}
public boolean isInfoEnabled() {
return lowestLevel.ordinal() <= Level.INFO.ordinal();
}
public boolean isWarnEnabled() {
return lowestLevel.ordinal() <= Level.WARN.ordinal();
}
public boolean isErrorEnabled() {
return lowestLevel.ordinal() <= Level.ERROR.ordinal();
}
public void log(Level level, Object... args) {
if (lowestLevel.ordinal() <= level.ordinal()) {
out.write(level + " - " + util.format(args) + "\n");
Util.get().debug(level + " - " + util.format(args));
}
}
public void debug(Object... args) {
log(Level.DEBUG, args);
}
public void info(Object... args) {
log(Level.INFO, args);
}
public void warn(Object... args) {
log(Level.WARN, args);
}
public void error(Object... args) {
log(Level.ERROR, args);
}
public static enum Level {
DEBUG,
INFO,
WARN,
ERROR
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy