diff mde/setup/Init.d @ 67:108d123238c0

Changes to work with tango r3700 (post 0.99.6). Changes to logging. Replaced many uses of PathView with FilePath.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 03 Jul 2008 12:40:31 +0100
parents cc3763817b8a
children 3dfd934100f7
line wrap: on
line diff
--- a/mde/setup/Init.d	Sun Jun 29 15:40:37 2008 +0100
+++ b/mde/setup/Init.d	Thu Jul 03 12:40:31 2008 +0100
@@ -37,15 +37,9 @@
 import tango.io.Console;	// for printing command-line usage
 import TimeStamp = tango.text.convert.TimeStamp, tango.time.WallClock;	// output date in log file
 import tango.util.Arguments;
-import tango.util.log.Log : Log, Logger;
-import tango.util.log.ConsoleAppender : ConsoleAppender;
-
-//version = SwitchAppender;
-version (SwitchAppender) {  // My own variation, currently just a test
-    import tango.util.log.SwitchingFileAppender : SwitchingFileAppender;
-} else {
-    import tango.util.log.RollingFileAppender : RollingFileAppender;
-}
+import tango.util.log.Log : Log, Logger, Level;
+import tango.util.log.AppendConsole;
+import tango.util.log.AppendFiles;
 
 // Derelict imports
 import derelict.opengl.gl;
@@ -62,12 +56,12 @@
  */
 static this()
 {
-    Logger root = Log.getRootLogger();
+    Logger root = Log.root;
     // Set the level here, but set it again once options have been loaded:
-    debug root.setLevel(root.Level.Trace);
-    else root.setLevel(root.Level.Info);
+    debug root.level(Logger.Trace);
+    else  root.level(Logger.Info);
     // Temporarily log to the console (until we've found paths and loaded options):
-    root.addAppender(new ConsoleAppender);
+    root.add(new AppendConsole);
 }
 static ~this()
 {
@@ -167,35 +161,31 @@
             }
             
 	    // Where logging is done to is determined at compile-time, currently just via static ifs.
-            root = Log.getRootLogger();
-	    root.clearAppenders;	// we may no longer want to log to the console
+            root = Log.root;
+	    root.clear;			// we may no longer want to log to the console
 	    
             // Now re-set the logging level, using the value from the config file:
-            root.setLevel (cast(Log.Level) (miscOpts.logOptions & LOG.LEVEL), true);
+            root.level (cast(Level) (miscOpts.logOptions & LOG.LEVEL), true);
             
             // Log to a file (first appender so root seperator messages don't show on console):
             if (miscOpts.logOptions & LOG.ROLLFILE) {
-                version (SwitchAppender) {
-                    root.addAppender (new SwitchingFileAppender (paths.logDir~"/log-.txt", 5));
-                } else {
                 // Use 2 log files with a maximum size of 1 MB:
-                    root.addAppender (new RollingFileAppender (paths.logDir~"/log-.txt", 2, 1024*1024));
-                    root.info (""); // some kind of separation between runs
-                    root.info ("");
-                }
+                root.add (new AppendFiles (paths.logDir~"/log-.txt", 2, 1024*1024));
+                root.info (""); // some kind of separation between runs
+                root.info ("");
             } else if (!(miscOpts.logOptions & LOG.CONSOLE)) {
                 // make sure at least one logger is enabled
                 miscOpts.set!(int) ("logOptions", miscOpts.logOptions | LOG.CONSOLE);
             }
             if (miscOpts.logOptions & LOG.CONSOLE) {	// Log to the console
-                root.addAppender(new ConsoleAppender);
+                root.add(new AppendConsole);
             }
             logger.info ("Starting mde [no version] on " ~ TimeStamp.toString(WallClock.now));
         } catch (Exception e) {
             // Presumably it was only adding a file appender which failed; set up a new console
             // logger and if that fails let the exception kill the program.
-            root.clearAppenders;
-            root.addAppender (new ConsoleAppender);
+            root.clear;
+            root.add (new AppendConsole);
             logger.warn ("Exception while setting up the logger; logging to the console instead.");
         }