Esempio n. 1
0
void PipelineExecutor::setLogStream(std::ostream& strm)
{

    LogPtr log = pdal::LogPtr(new pdal::Log("pypipeline", &strm));
    log->setLevel(m_logLevel);
    m_manager.setLog(log);

}
Esempio n. 2
0
TEST(SQLiteTest, testVersionInfo)
{
    LogPtr log = std::shared_ptr<pdal::Log>(new pdal::Log("spver", "stdout"));
    log->setLevel(LogLevel::Debug);

    const std::string filename(Support::temppath("spver.sqlite"));

    FileUtils::deleteFile(filename);

    SQLite db(filename, LogPtr(log));
    db.connect(true);
    db.loadSpatialite();

    const std::string p = db.getSQLiteVersion();
    EXPECT_EQ(p[0], '3'); // 3.8.9 as of this commit

    const std::string q = db.getSpatialiteVersion();
    EXPECT_EQ(q[0], '4'); // 4.2.0 as of this commit

//    FileUtils::deleteFile(filename);
}
Esempio n. 3
0
File: pdal.cpp Progetto: PDAL/PDAL
int App::execute(StringList& cmdArgs, LogPtr& log)
{
    ProgramArgs args;

    addArgs(args);
    try
    {
        args.parseSimple(cmdArgs);
    }
    catch (arg_val_error const& e)
    {
        Utils::printError(e.what());
        return -1;
    }

    log.reset(new Log("PDAL", m_log, m_logtiming));
    if (m_logLevel != LogLevel::None)
        log->setLevel(m_logLevel);
    else if (m_debug)
        log->setLevel(LogLevel::Debug);
    log->get(LogLevel::Debug) << "Debugging..." << std::endl;
    PluginManager<Stage>::setLog(log);
    PluginManager<Kernel>::setLog(log);
#ifndef _WIN32
    if (m_debug)
    {
        signal(SIGSEGV, [](int sig)
        {
            logPtr->get(LogLevel::Debug) << "Segmentation fault (signal 11)\n";
            StringList lines = Utils::backtrace();

            for (const auto& l : lines)
                logPtr->get(LogLevel::Debug) << l << std::endl;
            exit(1);
        });
    }
#endif

    m_command = Utils::tolower(m_command);
    if (!m_command.empty())
    {
        int ret = 0;
        std::string name("kernels." + m_command);

        Kernel *kernel = PluginManager<Kernel>::createObject(name);
        if (kernel)
        {
            if (m_help)
                cmdArgs.push_back("--help");
            // This shouldn't throw.  If it does, it's something awful, so
            // not cleaning up seems inconsequential.
            log->setLeader("pdal " + m_command);
            ret = kernel->run(cmdArgs, log);
            delete kernel;
            // IMPORTANT - The kernel must be destroyed before GDAL
            //  drivers are unregistered or GDAL will attempt to destroy
            //  resources more than once, resulting in a crash.
            gdal::unregisterDrivers();
        }
        else
            log->get(LogLevel::Error) << "Command '" << m_command <<
                "' not recognized" << std::endl << std::endl;
        return ret;
    }

    if (m_showVersion)
        outputVersion();
    else if (m_showDrivers)
        outputDrivers();
    else if (m_showOptions.size())
    {
        if (m_showOptions == "all")
            outputOptions();
        else
            outputOptions(m_showOptions, m_out);
    }
    else
        outputHelp(args);
    return 0;
}