program_wide_logger.h

Go to the documentation of this file.
00001 #ifndef PROGRAM_WIDE_LOGGER_GROUP
00002 #define PROGRAM_WIDE_LOGGER_GROUP
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : program_wide_logger facility                                      *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1992-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "build_configuration.h"
00019 
00020 // forward.
00021 class locked_logger;
00022 class log_base;
00023 
00024 /* @file program_wide_logger.h
00025  Provides a per-program logging subsystem that can be used from almost
00026  anywhere in the source code.  It is important that the very lowest-level
00027  code in basis not do pwl-logging, since those classes are used to implement
00028  the program wide logger.
00029 */
00030 
00031 // the program wide logger feature is a globally defined log_base object that
00032 // can be switched out to perform different types of logging.
00033 
00034 /*
00035  // a clue for static applications; gendeps will still see the include.
00036  #include <loggers/program_wide_logger.cpp>
00037 */
00038 
00039 #ifndef OMIT_PROGRAM_WIDE_LOGGER
00040   log_base BASIS_EXTERN &program_wide_logger();
00042 
00046   locked_logger BASIS_EXTERN &real_program_wide_logger();
00048 
00049   log_base BASIS_EXTERN *retask_program_wide_logger(log_base *new_logger);
00051 
00055 #else
00056   // faux logger for when we don't want to have all the machinery hooked in.
00057   #define program_wide_logger real_program_wide_logger
00058   #include <stdio.h>
00059   #ifndef __WIN32__
00060     #define EOL_FOR_LOCKED_LOGGER "\n"
00061   #else
00062     #define EOL_FOR_LOCKED_LOGGER "\r\n"
00063   #endif
00064   class locked_logger : public virtual object_base
00065   { public: IMPLEMENT_CLASS_NAME("locked_logger");
00066     outcome log(const istring &s, int formal(filt) = 0)
00067         { printf("%s" EOL_FOR_LOCKED_LOGGER, s.s()); return common::OKAY; }
00068     bool member(int formal(to_check)) { return true; }
00069     void eol(int formal(to_set)) {}
00070   };
00071   locked_logger BASIS_EXTERN &real_program_wide_logger();
00072 #endif
00073 
00074 #endif // outer guard.
00075 

Generated on Fri Nov 21 04:29:39 2008 for HOOPLE Libraries by  doxygen 1.5.1