application.cpp

Go to the documentation of this file.
00001 /*
00002   CLAW - a C++ Library Absolutely Wonderful
00003 
00004   CLAW is a free library without any particular aim but being useful to 
00005   anyone.
00006 
00007   Copyright (C) 2005-2008 Julien Jorge
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023   contact: julien_jorge@yahoo.fr
00024 */
00030 #include "claw/application.hpp"
00031 #include <claw/logger.hpp>
00032 
00033 /*----------------------------------------------------------------------------*/
00042 claw::application::application( int& argc, char** &argv )
00043   : m_arguments( argc, argv )
00044 {
00045   m_arguments.add_long("--log-file",
00046                        "The file to use to store log informations.", true,
00047                        "file" );
00048   m_arguments.add_long("--log-level",
00049                        "Level of log informations:\n"
00050            "\t\terror: error messages,\n"
00051                        "\t\twarning: warning and error messages,\n"
00052                        "\t\tverbose: all messages.", true, "string" );
00053   
00054   if ( m_arguments.has_value("--log-file") )
00055     {
00056       std::string log_file = m_arguments.get_string("--log-file");
00057       logger.set( new file_logger(log_file) );
00058     }
00059   else
00060     logger.set( new console_logger() );
00061 
00062   if ( m_arguments.has_value( "--log-level" ) )
00063     {
00064       std::string level = m_arguments.get_string("--log-level");
00065 
00066       if (level == "error")
00067   logger.set_level( log_error );
00068       else if (level == "warning")
00069   logger.set_level( log_warning );
00070       else if (level == "verbose")
00071   logger.set_level( log_verbose );
00072       else
00073   logger.set_level( m_arguments.get_integer("--log-level") );
00074     }
00075 
00076 } // application::application()
00077 
00078 /*----------------------------------------------------------------------------*/
00082 claw::application::~application()
00083 {
00084   logger.clear();
00085 } // application::~application()

Generated on Thu May 22 21:07:35 2008 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.5.5