Mercurial > projects > mde
comparison mde/setup/LogLayout.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 | |
children |
comparison
equal
deleted
inserted
replaced
177:af40e9679436 | 178:62aa8845edd2 |
---|---|
1 /* LICENSE BLOCK | |
2 Part of mde: a Modular D game-oriented Engine | |
3 Copyright © 2007-2008 Diggory Hardy | |
4 | |
5 This program is free software: you can redistribute it and/or modify it under the terms | |
6 of the GNU General Public License as published by the Free Software Foundation, either | |
7 version 2 of the License, or (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | |
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 See the GNU General Public License for more details. | |
12 | |
13 You should have received a copy of the GNU General Public License | |
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
15 | |
16 /************************************************************************************************** | |
17 * Provides coloured log output. | |
18 *************************************************************************************************/ | |
19 module mde.setup.LogLayout; | |
20 | |
21 import tango.util.log.Log; | |
22 | |
23 public class LayoutTimerColour : Appender.Layout | |
24 { | |
25 this () { | |
26 colour = ["\033[0;37m", "\033[0;0m", "\033[0;33m", "\033[0;31m", "\033[0;35m"]; | |
27 bold = ["\033[1;30m", "\033[1;1m", "\033[1;33m", "\033[1;31m", "\033[1;35m"]; | |
28 } | |
29 | |
30 void format (LogEvent event, size_t delegate(void[]) dg) | |
31 { | |
32 char[20] tmp = void; | |
33 size_t i = cast(size_t)event.level; | |
34 if (i >= 5) i = 1; | |
35 | |
36 dg ("\033[1;97m"); | |
37 dg (event.toMilli (tmp, event.span)); | |
38 dg ("\t"); | |
39 // dg (Thread.getThis.name); | |
40 // dg (" "); | |
41 dg (bold[i]); | |
42 dg (event.levelName); | |
43 dg (colour[i]); | |
44 dg (event.name); | |
45 dg (event.host.context.label); | |
46 dg (bold[i]); | |
47 dg (" - "); | |
48 dg (colour[i]); | |
49 dg (event.toString); | |
50 dg ("\033[0;00m"); | |
51 } | |
52 | |
53 char[][] colour, bold; | |
54 } |