diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tango/tango/util/log/ConsoleAppender.d	Fri Jan 11 17:57:40 2008 +0100
@@ -0,0 +1,83 @@
+/*******************************************************************************
+
+        copyright:      Copyright (c) 2004 Kris Bell. All rights reserved
+
+        license:        BSD style: $(LICENSE)
+      
+        version:        Initial release: May 2004
+        
+        author:         Kris
+
+*******************************************************************************/
+
+module tango.util.log.ConsoleAppender;
+
+private import tango.util.log.Appender;
+
+private import tango.io.Console;
+
+/*******************************************************************************
+
+        Append to the console. This will use either streams or tango.io
+        depending upon configuration
+
+*******************************************************************************/
+
+public class ConsoleAppender : Appender
+{
+        private Mask mask;
+
+        /***********************************************************************
+                
+                Create with the given Layout
+
+        ***********************************************************************/
+
+        this (EventLayout layout = null)
+        {
+                // Get a unique fingerprint for this class
+                mask = register (getName);
+
+                setLayout (layout);
+        }
+
+        /***********************************************************************
+                
+                Return the fingerprint for this class
+
+        ***********************************************************************/
+
+        Mask getMask ()
+        {
+                return mask;
+        }
+
+        /***********************************************************************
+                
+                Return the name of this class
+
+        ***********************************************************************/
+
+        char[] getName ()
+        {
+                return this.classinfo.name;
+        }
+                
+        /***********************************************************************
+               
+                Append an event to the output.
+                 
+        ***********************************************************************/
+
+        void append (Event event)
+        {
+                synchronized (Cerr)
+                             {
+                             auto layout = getLayout;
+                             Cerr (layout.header  (event));
+                             Cerr (layout.content (event));
+                             Cerr (layout.footer  (event));                        
+                             Cerr.newline;
+                             }
+        }
+}