- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Utils/Io/Xml/LoggingErrorHandler.cpp

    00001
    00002 //
    00003 // Copyright (c) 2005           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00010
    00011 #include "LoggingErrorHandler.h"
    00012 #include "ScopedTranscoder.h"
    00013
    00015
    00016 using namespace Mers::Utils::Io::Xml;
    00017 using Mers::Utils::Lang::String;
    00018 using log4cplus::Logger;
    00019 using XERCES_CPP_NAMESPACE::SAXParseException;
    00020
    00022
    00023 Logger LoggingErrorHandler::s_logger
    00024 ( Logger::getInstance( "Mers.Utils.Io.Xml.LoggingErrorHandler" ) );
    00025
    00027
    00028 LoggingErrorHandler::LoggingErrorHandler( const Logger &logger )
    00029         : m_logger( logger )
    00030 {
    00031 }
    00032
    00034
    00035 void LoggingErrorHandler::warning(const SAXParseException &exc)
    00036 {
    00037         // Log the warning.
    00038         LOG4CPLUS_WARN_STR( m_logger, formatMessage( exc ).c_str() );
    00039 }
    00040
    00042
    00043 void LoggingErrorHandler::error (const SAXParseException &exc)
    00044 {
    00045         // Log the error.
    00046         LOG4CPLUS_ERROR_STR( m_logger, formatMessage( exc ).c_str() );
    00047 }
    00048
    00050
    00051 void LoggingErrorHandler::fatalError (const SAXParseException &exc)
    00052 {
    00053         // Log the error.
    00054         LOG4CPLUS_FATAL_STR( m_logger, formatMessage( exc ).c_str() );
    00055 }
    00056
    00058
    00059 void LoggingErrorHandler::resetErrors ()
    00060 {
    00061         // Nothing to do.  We keep the same logger.
    00062 }
    00063
    00065
    00066 String LoggingErrorHandler::formatMessage(const SAXParseException &exc)
    00067 {
    00068         CScopedTranscoder message( exc.getMessage() );
    00069
    00070         // Encode the message.
    00071         String fMessage("line ");
    00072         fMessage += exc.getLineNumber();
    00073         fMessage.append( " (col " );
    00074         fMessage += exc.getColumnNumber();
    00075         fMessage.append( "): " );
    00076         fMessage.append( message );
    00077         return fMessage;
    00078 }
    00079
    00081