Mercurial > projects > ldc
comparison tango/tango/util/log/ConsoleAppender.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
1 /******************************************************************************* | |
2 | |
3 copyright: Copyright (c) 2004 Kris Bell. All rights reserved | |
4 | |
5 license: BSD style: $(LICENSE) | |
6 | |
7 version: Initial release: May 2004 | |
8 | |
9 author: Kris | |
10 | |
11 *******************************************************************************/ | |
12 | |
13 module tango.util.log.ConsoleAppender; | |
14 | |
15 private import tango.util.log.Appender; | |
16 | |
17 private import tango.io.Console; | |
18 | |
19 /******************************************************************************* | |
20 | |
21 Append to the console. This will use either streams or tango.io | |
22 depending upon configuration | |
23 | |
24 *******************************************************************************/ | |
25 | |
26 public class ConsoleAppender : Appender | |
27 { | |
28 private Mask mask; | |
29 | |
30 /*********************************************************************** | |
31 | |
32 Create with the given Layout | |
33 | |
34 ***********************************************************************/ | |
35 | |
36 this (EventLayout layout = null) | |
37 { | |
38 // Get a unique fingerprint for this class | |
39 mask = register (getName); | |
40 | |
41 setLayout (layout); | |
42 } | |
43 | |
44 /*********************************************************************** | |
45 | |
46 Return the fingerprint for this class | |
47 | |
48 ***********************************************************************/ | |
49 | |
50 Mask getMask () | |
51 { | |
52 return mask; | |
53 } | |
54 | |
55 /*********************************************************************** | |
56 | |
57 Return the name of this class | |
58 | |
59 ***********************************************************************/ | |
60 | |
61 char[] getName () | |
62 { | |
63 return this.classinfo.name; | |
64 } | |
65 | |
66 /*********************************************************************** | |
67 | |
68 Append an event to the output. | |
69 | |
70 ***********************************************************************/ | |
71 | |
72 void append (Event event) | |
73 { | |
74 synchronized (Cerr) | |
75 { | |
76 auto layout = getLayout; | |
77 Cerr (layout.header (event)); | |
78 Cerr (layout.content (event)); | |
79 Cerr (layout.footer (event)); | |
80 Cerr.newline; | |
81 } | |
82 } | |
83 } |