void MainApplication::initializeLogging(BoostPath KELogFilePath)
{
    if(_EnableLogging)
    {
        //Configure the LogBuffer
        osgLogP->setLogType(LOG_BUFFER, true);

        //Configure the LogBuffer
        osgLogP->getLogBuf().setEnabled(true);
        osgLogP->getLogBuf().setCallback(KELogBufferCallback);

        if(_LogToFile)
        {
            //Make sure the directory is created
            try
            {
                boost::filesystem::create_directories(KELogFilePath.parent_path());
            }
            catch(std::exception& ex)
            {
                SWARNING << "Failed to create directory: " << KELogFilePath.parent_path() 
                    << ", error: " << ex.what() << std::endl;
                return;
            }

            //If the Log is to a file then set the filev
            _LogFile.open(KELogFilePath.string().c_str());
        }
    }
    else
    {
        //Disable all logging
        osgLogP->setLogType(LOG_NONE, true);
    }
}
OSG_BEGIN_NAMESPACE

/***************************************************************************\
 *                           Class variables                               *
\***************************************************************************/

/***************************************************************************\
 *                           Class methods                                 *
\***************************************************************************/

/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/

bool ApplicationSettings::writeXML(const BoostPath& FilePath)
{
    //Make sure the directory is created
    try
    {
        boost::filesystem::create_directories(FilePath.parent_path());
    }
    catch(std::exception& ex)
    {
        SWARNING << "Failed to create directory: " << FilePath.parent_path() 
                 << ", error: " << ex.what() << std::endl;
	    return false;
    }

    //Write the XML
    try
    {
        boost::property_tree::xml_parser::write_xml(FilePath.string(), 
                                                    _PropertyTree, 
                                                    std::locale(), 
                                                    boost::property_tree::xml_parser::xml_writer_make_settings<boost::property_tree::ptree::key_type::value_type>(' ', 4));
    }
    catch(std::exception& ex)
    {
        SWARNING << "Failed to write settings to file: " << FilePath.string() 
                 << ", error: " << ex.what() << std::endl;
	    return false;
    }
	return true;
}
boost::any LuaGraphTreeModel::getParent(const boost::any& node) const
{
    try
    {
        BoostPath ThePath = boost::any_cast<BoostPath>(node);

        if((!ThePath.empty() ||
            ThePath == getInternalRoot() ||
            boost::filesystem::equivalent(ThePath, getInternalRoot())) &&
           (boost::filesystem::exists(ThePath) && boost::filesystem::exists(getInternalRoot())))
        {
            return boost::any(ThePath.parent_path());
        }

    }
    catch(boost::bad_any_cast &)
    {
    }
    return boost::any();
}