log_init.c

Go to the documentation of this file.
00001 /*!
00002  * \file   log/lib/src/log_init.c
00003  * \brief  Initialize the LOG_tag
00004  *
00005  * \date   02/13/2003
00006  * \author Jork Loeser <jork.loeser@inf.tu-dresden.de>
00007  *
00008  */
00009 /* (c) 2003 Technische Universitaet Dresden
00010  * This file is part of DROPS, which is distributed under the terms of the
00011  * GNU General Public License 2. Please see the COPYING file for details.
00012  */
00013 
00014 #include <l4/log/l4log.h>
00015 #include <l4/crtx/ctor.h>
00016 #include <l4/util/mbi_argv.h>
00017 char LOG_tag[9] __attribute__((weak));
00018 char LOG_tag[9] = "";
00019 
00020 /* Initialize the LOG_tag after the cmdline has been parsed, but before
00021  * the l4env or other systems come up.
00022  */
00023 L4C_CTOR(LOG_setup_tag, L4CTOR_BEFORE_BACKEND);
00024 
00025 /*!\brief Set the LOG tag.
00026  *
00027  * This function should be called by the startup-code, prior to any output
00028  * of the loglib (if used) or the thread-creation using the thread package.
00029  * If l4util_progname is empty, it will be filled with the first 8 chars of
00030  * the last portion of the program name.
00031  *
00032  * With L4Env, this function is called after initializing l4util's argc/argv.
00033  * It is called via constructors a second time before calling main().
00034  * Without L4Env and the __main() from l4util, this function is called
00035  * as constructor after initializing argc/argv.
00036  */
00037 void LOG_setup_tag(void)
00038 {
00039   const char *name = l4util_argv[0];
00040 
00041   if (!name)
00042     return;
00043 
00044   if (LOG_tag[0] == 0)
00045     {
00046       char *d;
00047       const char *e;
00048 
00049       /* look for last '/' in name */
00050       for (e = name; *e; e++)
00051         if (*e == '/')
00052           name = e + 1;
00053 
00054       e = LOG_tag + sizeof(LOG_tag) - 1;
00055       for (d = LOG_tag; *name && d < e; )
00056         *d++ = *name++;
00057       *d = 0;
00058     }
00059 }

Generated on Wed Apr 11 06:40:52 2012 for Logging and output facility for DROPS by  doxygen 1.5.6