moved log to own package
This commit is contained in:
48
src/kernel/log/Log.hx
Normal file
48
src/kernel/log/Log.hx
Normal file
@@ -0,0 +1,48 @@
|
||||
package kernel.log;
|
||||
|
||||
#if webconsole
|
||||
import lib.Debug;
|
||||
#end
|
||||
|
||||
/**
|
||||
Log messages to specified output.
|
||||
**/
|
||||
class Log {
|
||||
private static inline final MAX_LINES:Int = 100;
|
||||
|
||||
private static final logLines:Array<LogLine> = [];
|
||||
|
||||
public static function info(msg:Dynamic, ?pos:haxe.PosInfos) {
|
||||
log({level: Info, message: Std.string(msg),time: 0});
|
||||
}
|
||||
|
||||
public static function warn(msg:Dynamic, ?pos:haxe.PosInfos) {
|
||||
log({level: Warn, message: Std.string(msg),time: 0});
|
||||
}
|
||||
|
||||
public static function error(msg:Dynamic, ?pos:haxe.PosInfos) {
|
||||
log({level: Error, message: Std.string(msg),time: 0});
|
||||
}
|
||||
|
||||
public static function debug(msg:Dynamic, ?pos:haxe.PosInfos) {
|
||||
#if debug
|
||||
log({level: Debug, message: Std.string(msg),time: 0});
|
||||
#end
|
||||
}
|
||||
|
||||
public static function silly(msg:Dynamic, ?pos:haxe.PosInfos) {
|
||||
log({level: Silly, message: Std.string(msg),time: 0});
|
||||
}
|
||||
|
||||
private static function log(line: LogLine, ?pos:haxe.PosInfos) {
|
||||
logLines.push(line);
|
||||
|
||||
if (logLines.length > MAX_LINES) {
|
||||
logLines.shift();
|
||||
}
|
||||
|
||||
#if webconsole
|
||||
Debug.printWeb('[${Std.string(line.level)}] ${line.message}');
|
||||
#end
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user