view tango/tango/util/log/ConsoleAppender.d @ 341:1bb99290e03a trunk

[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author lindquist
date Sun, 13 Jul 2008 02:51:19 +0200
parents 1700239cab2e
children
line wrap: on
line source

/*******************************************************************************

        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;
                             }
        }
}