Logger 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace tera.commons.utils
{
public enum LogLevel
{
DEBUG,
INFO,
ERROR,
FATAL,
}
public class Logger
{
public static LogLevel logLevel = 0;
public static void debug(String msg)
{
log(LogLevel.DEBUG, msg);
}
public static void info(String msg)
{
log(LogLevel.INFO, msg);
}
public static void error(String msg)
{
log(LogLevel.ERROR, msg);
}
public static void fatal(String msg)
{
log(LogLevel.FATAL, msg);
}
private static void log(LogLevel level, String msg)
{
if (!logLevel.HasFlag(level))
return;
Console.WriteLine("{0} : {1}"
, DateTime.Now.ToString("hh:mm:ss")
, msg);
}
}
}
Related examples in the same category