1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
/*
* $Id: logger.d,v 1.1.1.1 2006/11/19 07:54:55 kenta Exp $
*
* Copyright 2006 Kenta Cho. Some rights reserved.
*/
module abagames.util.logger;
private import std.stdio;
private import std.string;
private import std.conv;
/**
* Logger for error and info messages.
*/
version(Win32_release) {
private import std.string;
private import std.c.windows.windows;
public class Logger {
public static void info(string msg, bool nline = true) {
}
public static void info(double n, bool nline = true) {
}
private static void putMessage(string msg) {
MessageBoxA(null, std.string.toStringz(msg), "Error", MB_OK | MB_ICONEXCLAMATION);
}
public static void error(string msg) {
putMessage("Error: " ~ msg);
}
public static void error(Throwable e) {
putMessage("Error: " ~ e.toString());
}
}
} else {
public class Logger {
public static void info(string msg, bool nline = true) {
if (nline)
writefln(msg);
else
writef(msg);
}
public static void info(double n, bool nline = true) {
if (nline)
writefln(to!string(n));
else
writef(to!string(n));
}
public static void error(string msg) {
writefln("Error: %s", msg);
}
public static void error(Throwable e) {
writefln("Error: %s", e.toString());
if (e.next)
error(e.next);
}
}
}
|