Mercurial > projects > mde
diff mde/setup/Init.d @ 178:62aa8845edd2
Coloured log output to the console.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 15 Sep 2009 10:36:37 +0200 |
parents | a1ba9157510e |
children |
line wrap: on
line diff
--- a/mde/setup/Init.d Sat Sep 12 09:50:33 2009 +0200 +++ b/mde/setup/Init.d Tue Sep 15 10:36:37 2009 +0200 @@ -43,6 +43,7 @@ import mde.setup.InitStage; // Controls external delegates run by init import mde.setup.exception; import mde.setup.logger; +import mde.setup.LogLayout; import mde.content.AStringContent; import mde.content.ContentLoader; @@ -89,6 +90,7 @@ ["Trace", "Info", "Warn", "Error", "Fatal", "None"]); logOutput = new EnumContent ("MiscOptions.logOutput", ["both", "file", "console", "none"]); + logColour = new BoolContent ("MiscOptions.logColour"); // Callback to set the logging level on change: logLevel.addCallback (&setLogLevel); @@ -160,6 +162,9 @@ // Where logging is done to is determined at compile-time, currently just via static ifs. root = Log.root; root.clear; // we may no longer want to log to the console + Appender.Layout layout = null; + if (logColour()) + layout = new LayoutTimerColour(); // logOutput == 0 enables both outputs, in case options aren't read if (!(logOutput() & 2)) { // first appender so root seperator messages don't show on console @@ -169,7 +174,7 @@ root.append (Level.None, ""); } if (!(logOutput() & 1)) - root.add(new AppendConsole); + root.add(new AppendConsole (layout)); } 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. @@ -399,7 +404,7 @@ private static { Logger logger; - BoolContent exitImmediately; + BoolContent exitImmediately, logColour; IntContent maxThreads; EnumContent logLevel, logOutput;