Beispiel #1
0
    void format_entity(const Formatter& f, const Entity& e,
        const bool empty_out_content = false) {
        const auto fn(f.ownership_hierarchy().formatter_name());
        BOOST_LOG_SEV(lg, debug) << "Formatting: '" << e.name()
                                 << "' with '" << fn << "'";

        const auto ctx(factory_.make(e.id()));
        const auto fp(ctx.formatter_properties());
        const auto i(fp.find(fn));
        if (i == fp.end()) {
            BOOST_LOG_SEV(lg, error) << formatter_properties_not_found << fn;
            BOOST_THROW_EXCEPTION(
                workflow_error(formatter_properties_not_found + fn));
        }

        const auto is_formatter_enabled(i->second.enabled());
        if (!is_formatter_enabled) {
            BOOST_LOG_SEV(lg, debug) << "Formatter not enabled for type.";
            return;
        }

        auto file(f.format(ctx, e));

        if (empty_out_content) {
            BOOST_LOG_SEV(lg, debug) << "Emptying out content.";
            file.content().clear();
        }

        files_.push_front(file);
        if (!file.overwrite()) {
            BOOST_LOG_SEV(lg, debug) << "Filename: "
                                     << file.path().generic_string();
            BOOST_LOG_SEV(lg, debug) << "Content: "
                                     << (file.content().empty() ? "<empty>" :
                                         file.content());
            BOOST_LOG_SEV(lg, debug) << "Finished formatting: '" << e.name()
                                     << "'";
        } else {
            BOOST_LOG_SEV(lg, debug) << "Not dumping file contents to log "
                                     << "(overwrite is false).";
        }
    }
Beispiel #2
0
    void format(const Formatter& f, const Formatable& e,
        const bool empty_out_content = false) {
        const auto fn(f.ownership_hierarchy().formatter_name());
        BOOST_LOG_SEV(lg, debug) << "Formatting with: '" << fn << "'";

        auto file(f.format(factory_.make_empty_context(), e));

        if (empty_out_content) {
            BOOST_LOG_SEV(lg, debug) << "Emptying out content.";
            file.content().clear();
        }

        files_.push_front(file);
        if (!file.overwrite()) {
            BOOST_LOG_SEV(lg, debug) << "Filename: "
                                     << file.path().generic_string();
            BOOST_LOG_SEV(lg, debug) << "Content: "
                                     << (file.content().empty() ? "<empty>" :
                                         file.content());
        } else {
            BOOST_LOG_SEV(lg, debug) << "Not dumping file contents to log "
                                     << "(overwrite is false).";
        }
    }