diff --git a/src/lib/nobugcfg.cpp b/src/common/logging.cpp similarity index 60% rename from src/lib/nobugcfg.cpp rename to src/common/logging.cpp index ecbde0e79..6a3e265a7 100644 --- a/src/lib/nobugcfg.cpp +++ b/src/common/logging.cpp @@ -1,47 +1,37 @@ /* - NoBugCfg - NoBug definitions and initialisation for the Proc-Layer - + logging.cpp - Configure basic nobug logging + Copyright (C) Lumiera.org - 2008, Christian Thaeter - + 2008, 2009 Christian Thaeter + Hermann Vosseler + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -* *****************************************************/ +*/ -#include "include/nobugcfg.h" +#define LOGGING_C -#define NOBUG_INIT_DEFS_ -#include "include/nobugcfg.h" -#undef NOBUG_INIT_DEFS_ - - - - -namespace lumiera { - - void - initialise_NoBug () - { - NOBUG_INIT; - -#ifdef DEBUG - static uint callCount = 0; - ASSERT ( 0 == callCount++ ); -#endif - } - -} +/* + logging.h defines the flags here, thats all + */ +#include "logging.h" +/* +// Local Variables: +// mode: C +// c-file-style: "gnu" +// indent-tabs-mode: nil +// End: +*/ diff --git a/src/common/logging.h b/src/common/logging.h new file mode 100644 index 000000000..40d4aaa5b --- /dev/null +++ b/src/common/logging.h @@ -0,0 +1,162 @@ +/* + logging.h - Configure basic nobug logging + + Copyright (C) Lumiera.org + 2008, 2009 Christian Thaeter + Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef LUMIERA_LOGGING_H +#define LUMIERA_LOGGING_H + +/** @file logging.h + ** This header is for including and configuring NoBug. + ** The idea is that configuration and some commonly used flag + ** declarations are to be kept in one central location. Subsystems + ** are free to define and use additional flags for local use. Typically, + ** this header will be included via some of the basic headers like error.hpp, + ** which in turn gets included e.g. by proc/common.hpp + ** + ** This header can thus be assumed to be effectively global. It should contain + ** only declarations of global relevance, as any change causes the whole project + ** to be rebuilt. All flags defined here are automatic initialised. + ** + ** We use the 'NOBUG_DECLARATIONS_ONLY' magic to generate declarations and + ** definitions only out of this header. + ** + ** @par Logging configuration + ** By default, logging is configured such as to emit a small number of informative + ** messages on the starting terminal and to report fatal errors. But besides the + ** usual fine-grained tracing messages, we define a small number of distinct + ** thematic Logging Channels providing a consistent high-level view of + ** what is going on with regards to a specific aspect of the application + ** - \c progress documents a high-level overall view of what the application \em does + ** - \c render focuses on the working of the render engine (without logging each frame) + ** - \c config shows anything of relevance regarding the configured state of App and session + ** - \c memory allows to diagnose a high-level view of memory management + ** + ** Any log level can be overridden by an environment variable, for example + ** \code NOBUG_LOG='progress:INFO' ./lumiera \endcode + ** + ** @todo logging to files? NOBUG_LOG='progress:INFO@file(name=filename)' api to set this statically up by the program will follow --cehteh + ** @todo review this documentation ################################################################################################################################ + */ + + +#include + +#ifndef LUMIERA_LOGGING_C +#define NOBUG_DECLARE_ONLY 1 +#endif + +/** the root switch for all logging */ +NOBUG_CPP_DEFINE_FLAG (all); +/** debug logging */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( debugging, all); +/** debug logging for the main application starter */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( main_dbg, debugging); +/** base of debug logging for the backend */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( backend_dbg, debugging); +NOBUG_CPP_DEFINE_FLAG_PARENT ( file_dbg, backend_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( filehandle_dbg, backend_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( filehandlecache_dbg, backend_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( filedescriptor_dbg, backend_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( mmap_dbg, backend_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( mmapcache_dbg, backend_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( mmapings_dbg, backend_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( threads_dbg, backend_dbg); +/** base of debug logging for the proc layer */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( proc_dbg, debugging); +/** base of debug logging for the gui */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( gui_dbg, debugging); +/** base if debug logging for the support library */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( library_dbg, debugging); +NOBUG_CPP_DEFINE_FLAG_PARENT ( psplay_dbg, library_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( resourcecollector_dbg, library_dbg); +/** base of debug logging for the common library */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( common_dbg, debugging); +NOBUG_CPP_DEFINE_FLAG_PARENT ( config_dbg, common_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( configfile_dbg, config_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( configitem_dbg, config_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( configtyped_dbg, config_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( configlookup_dbg, config_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( interface_dbg, common_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( interfaceregistry_dbg, interface_dbg); +NOBUG_CPP_DEFINE_FLAG_PARENT ( plugin_dbg, common_dbg); +/** base of runtime logging always available */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( logging, all); +/** general application progress base */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( progress, logging); +/** progress log for the main starter */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( main, progress); +/** progress log for the backend */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( backend, progress); +NOBUG_CPP_DEFINE_FLAG_PARENT ( file, backend); //opening/closing files etc +/** progress log for the proc layer */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( proc, progress); +/** progress log for the render subsystem of proc */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( render, proc); //ichthyo: did you want this as global channel or as progress child? +/** progress log for the gui */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( gui, progress); +/** progress log for the support lib */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( library, progress); +NOBUG_CPP_DEFINE_FLAG_PARENT ( resourcecollector, library); +/** progress log for the common lib */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( common, progress); +/** progress log, config subsystem */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( config, common); +NOBUG_CPP_DEFINE_FLAG_PARENT ( configfiles, config); //reading, writing, lookup configfiles +NOBUG_CPP_DEFINE_FLAG_PARENT ( configtyped, config); //values queried, errors +/** progress log, interfaces */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( interface, common); +NOBUG_CPP_DEFINE_FLAG_PARENT ( interfaceregistry, common); //interfaces which get registered/removed +/** progress log, plugin loader*/ +NOBUG_CPP_DEFINE_FLAG_PARENT ( plugin, common); //plugins loaded/unloaded/errors +/** base flag for software testing */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( test, logging); +/** base flag for syncronization logging */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( sync, logging); +NOBUG_CPP_DEFINE_FLAG_PARENT ( mutex_sync, sync); //locking/unlocking mutexes +NOBUG_CPP_DEFINE_FLAG_PARENT ( condwait_sync, sync); //waiting and signalling condition vars +/** base flag for memory related logging */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( memory, logging); +/** memory busines of the proc layer */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( proc_mem, memory); +NOBUG_CPP_DEFINE_FLAG_PARENT ( mobject_mem, proc_mem); +NOBUG_CPP_DEFINE_FLAG_PARENT ( builder_mem, proc_mem); +NOBUG_CPP_DEFINE_FLAG_PARENT ( asset_mem, proc_mem); +/** event which drive the application are separately logged to reconstruct what happend/yielded to a problem */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( events, all); +/** caveat joel, you need to implement this */ +NOBUG_CPP_DEFINE_FLAG_PARENT ( gui_event, all); + + + +#ifndef LUMIERA_LOGGING_C +#undef NOBUG_DECLARE_ONLY +#define NOBUG_DECLARE_ONLY 0 +#endif + +#endif +/* +// Local Variables: +// mode: C +// c-file-style: "gnu" +// indent-tabs-mode: nil +// End: +*/ diff --git a/src/include/nobugcfg.h b/src/include/nobugcfg.h deleted file mode 100644 index 37b336503..000000000 --- a/src/include/nobugcfg.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - NOBUGCFG.h - NoBug definitions and initialisation for the Proc-Layer - - - Copyright (C) Lumiera.org - 2008, Christian Thaeter - Hermann Vosseler - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -/** @file nobugcfg.h - ** This header is for including and configuring NoBug. - ** The idea is that configuration and some commonly used flag - ** declarations are to be kept in one central location. Subsystems - ** are free to define and use additional flags for local use. Typically, - ** this header will be included via some of the basic headers like error.hpp, - ** which in turn gets included e.g. by proc/common.hpp - ** - ** This header can thus be assumed to be effectively global. It should contain - ** only declarations of global relevance, as any change causes the whole project - ** to be rebuilt. Moreover, for C++ this header assures automatic initialisation - ** of NoBug by placing a static ctor call. - ** - ** Besides the usual guarded declarations, this header contains one section - ** with the corresponding definitions. This section is to be included once - ** by some translation unit (currently this is lumiera/nobugcfg.cpp) in order to - ** generate the necessary definitions. - ** - ** @par Logging configuration - ** By default, logging is configured such as to emit a small number of informative - ** messages on the starting terminal and to report fatal errors. But besides the - ** usual fine-grained tracing messages, we define a small number of distinct - ** thematic Logging Channels providing a consistent high-level view of - ** what is going on with regards to a specific aspect of the application - ** - \c operate documents a high-level overall view of what the application \em does - ** - \c render focuses on the working of the render engine (without logging each frame) - ** - \c config shows anything of relevance regarding the configured state of App and session - ** - \c memory allows to diagnose a high-level view of memory management - ** - ** Any log level can be overridden by an environment variable, for example - ** \code NOBUG_LOG='operate:INFO' ./lumiera \endcode - ** - ** @todo logging to files? - */ - - -#ifndef NOBUGCFG_H /* ============= Part 1: DECLARATIONS ======== */ -#define NOBUGCFG_H - -#include -#include - - -#ifdef __cplusplus /* ============= C++ ================ */ - -#include "include/lifecycle.h" -#include "lib/error.hpp" ///< make assertions throw instead of abort() - -namespace lumiera { - void initialise_NoBug (); - namespace { - LifecycleHook trigger_it_ (ON_BASIC_INIT, &initialise_NoBug); -} } -#endif /* =====================(End) C++ ================ */ - - - - - /* declare flags used throughout the code base */ - NOBUG_DECLARE_FLAG (all); - NOBUG_DECLARE_FLAG (lumiera_all); - NOBUG_DECLARE_FLAG (lumiera); ///< master log, informative console output - NOBUG_DECLARE_FLAG (operate); ///< logging channel reporting what the application does - NOBUG_DECLARE_FLAG (render); ///< logging channel focusing on the render engine's workings - NOBUG_DECLARE_FLAG (config); ///< logging channel covering application and session configuration - NOBUG_DECLARE_FLAG (memory); ///< logging channel covering memory management issues - NOBUG_DECLARE_FLAG (sync); ///< especially for tracing synchronisation - NOBUG_DECLARE_FLAG (test); - - -#endif /*NOBUGCFG_H ======= (End) Part 1: DECLARATIONS ======== */ - - - - - - -#ifdef NOBUG_INIT_DEFS_ /*========== Part 2: DEFINITIONS ========= */ - - - /* flags used throughout the code base... */ - NOBUG_CPP_DEFINE_FLAG (all); - NOBUG_CPP_DEFINE_FLAG_PARENT (lumiera_all, all); - NOBUG_CPP_DEFINE_FLAG_PARENT (lumiera, lumiera_all); - NOBUG_CPP_DEFINE_FLAG_PARENT (config, lumiera); - NOBUG_CPP_DEFINE_FLAG_PARENT (operate, lumiera); - NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (render, lumiera, LOG_WARNING); - NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (memory, lumiera, LOG_WARNING); - NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (sync, memory, LOG_WARNING); - NOBUG_CPP_DEFINE_FLAG_PARENT_LIMIT (test, all, LOG_ERR); - - - - -#endif /*NOBUG_INIT_DEFS_ ==== (End) Part 2: DEFINITIONS ========= */