home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2004 August / GSSH0804.iso / Action / TumikiFighters / tf0_2.exe / tf / src / abagames / util / logger.d < prev    next >
Text File  |  2004-05-15  |  2KB  |  83 lines

  1. /*
  2.  * $Id: logger.d,v 1.3 2004/05/14 14:35:38 kenta Exp $
  3.  *
  4.  * Copyright 2003 Kenta Cho. All rights reserved.
  5.  */
  6. module abagames.util.logger;
  7.  
  8. private import std.stream;
  9. private import std.string;
  10.  
  11. /**
  12.  * Logger(error/info).
  13.  */
  14. version(Win32_release) {
  15.  
  16. import std.string;
  17. import std.c.windows.windows;
  18.  
  19. public class Logger {
  20.  
  21.   public static void info(char[] msg) {
  22.     // Win32 exe file crashes if it writes something to stderr.
  23.     //stderr.writeLine("Info: " ~ msg);
  24.   }
  25.  
  26.   public static void info(int n) {
  27.     //stderr.writeLine("Info: " ~ std.string.toString(n));
  28.   }
  29.  
  30.   public static void info(float n) {
  31.     //stderr.writeLine("Info: -" ~ std.string.toString(n));
  32.   }
  33.  
  34.   private static void putMessage(char[] msg) {
  35.     MessageBoxA(null, std.string.toStringz(msg), "Error", MB_OK | MB_ICONEXCLAMATION);
  36.   }
  37.  
  38.   public static void error(char[] msg) {
  39.     putMessage("Error: " ~ msg);
  40.   }
  41.  
  42.   public static void error(Exception e) {
  43.     putMessage("Error: " ~ e.toString());
  44.   }
  45.  
  46.   public static void error(Error e) {
  47.     putMessage("Error: " ~ e.toString());
  48.   }
  49. }
  50.  
  51. } else {
  52.  
  53. public class Logger {
  54.  
  55.   public static void info(char[] msg) {
  56.     stderr.writeLine("Info: " ~ msg);
  57.   }
  58.  
  59.   public static void info(int n) {
  60.     stderr.writeLine("Info: " ~ std.string.toString(n));
  61.   }
  62.  
  63.   public static void info(float n) {
  64.     stderr.writeLine("Info: -" ~ std.string.toString(n));
  65.   }
  66.  
  67.   public static void error(char[] msg) {
  68.     stderr.writeLine("Error: " ~ msg);
  69.   }
  70.  
  71.   public static void error(Exception e) {
  72.     stderr.writeLine("Error: " ~ e.toString());
  73.   }
  74.  
  75.   public static void error(Error e) {
  76.     stderr.writeLine("Error: " ~ e.toString());
  77.     if (e.next)
  78.       error(e.next);
  79.   }
  80. }
  81.  
  82. }
  83.