/* The software in this package is distributed under the GNU General Public License version 2 (with a special exception described below). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING.GPL. As a special exception, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other works to produce a work based on this file, this file does not by itself cause the resulting work to be covered by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ #include "host/logoutput.h" #include #include #include "boost_assert_handler.h" using namespace std; //----------------------------------------------------------------------------- // LogOutput //----------------------------------------------------------------------------- static map log_output_string_map; /** * @brief Transform the @a log_output_string into a @c LogOutput. * * @param log_output_string The string to be parsed. * * @return The @c LogOutput corresponding to the @a log_output_string. */ LogOutput get_log_output_from_string( const string &log_output_string ) { BOOST_ASSERT( !log_output_string.empty() ); // convert to uppercase to allow the protocol to be case insensitive string log_output_uppercase_string( log_output_string ); transform( log_output_string.begin(), log_output_string.end(), log_output_uppercase_string.begin(), ::toupper ); //lint !e534 // TODO move to an init method log_output_string_map[ "SYSLOG" ] = LogOutput_SYSLOG; log_output_string_map[ "TERMINAL" ] = LogOutput_TERMINAL; log_output_string_map[ "CONSOLE" ] = LogOutput_TERMINAL; log_output_string_map[ "STDERR" ] = LogOutput_TERMINAL; log_output_string_map[ "FILE" ] = LogOutput_FILE; LogOutput protocol = log_output_string_map[ log_output_uppercase_string ]; return protocol; }