class Paludis::Log

Singleton class that handles log messages.

Public Instance Methods

log_level → LogLevel click to toggle source

Fetch the current log level.

VALUE
    log_log_level(VALUE)
    {
        return INT2FIX(Log::get_instance()->log_level());
    }

    /*
     * call-seq:
     *     log_level=
     *
     * Only display messages of at least this level.
     */
    VALUE
    log_log_level_set(VALUE self, VALUE value)
    {
        int l = NUM2INT(value);
        if (l < 0 || l >= last_ll)
            rb_raise(rb_eTypeError, "Log.level= expects a valid LogLevel");
        Log::get_instance()->set_log_level(static_cast<LogLevel>(l));
        return self;
    }

    /*
     * call-seq:
     *     set_program_name(name)
     *
     * Set our program name.
     */
    VALUE
    log_set_program_name(VALUE self, VALUE name)
    {
        Log::get_instance()->set_program_name(stringify(StringValuePtr(name)));
        return self;
    }

    /*
     * call-seq:
     *     message(id, log_level, message)
     *
     * Log a message at the specified level.
     */
    VALUE
    log_message(VALUE self, VALUE id, VALUE log_level, VALUE message)
    {
        int l = NUM2INT(log_level);
        if (l < 0 || l >= last_ll)
            rb_raise(rb_eTypeError, "Log.log_message expects a valid LogLevel as the first parameter");
        Log::get_instance()->message(stringify(StringValuePtr(id)), static_cast<LogLevel>(l), lc_no_context)
            << stringify(StringValuePtr(message));
        return self;
    }

    void do_register_log()
    {
        rb_require("singleton");

        /*
         * Document-class: Paludis::Log
         *
         * Singleton class that handles log messages.
         */
        c_log = rb_define_class_under(c_paludis_module, "Log", rb_cObject);
        rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_log);
        rb_define_method(c_log, "log_level", log_log_level, 0);
        rb_define_method(c_log, "log_level=", log_log_level_set, 1);
        rb_define_method(c_log, "program_name=", log_set_program_name, 1);
        rb_define_method(c_log, "message", log_message, 3);

        /*
         * Document-module: Paludis::LogLevel
         *
         * Specifies the level of a log message
         */
        c_log_level = rb_define_module_under(c_paludis_module, "LogLevel");
        for (LogLevel l(static_cast<LogLevel>(0)), l_end(last_ll) ; l != l_end ;
                l = static_cast<LogLevel>(static_cast<int>(l) + 1))
            rb_define_const(c_log_level, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));

    }
}
log_level= click to toggle source

Only display messages of at least this level.

VALUE
    log_log_level_set(VALUE self, VALUE value)
    {
        int l = NUM2INT(value);
        if (l < 0 || l >= last_ll)
            rb_raise(rb_eTypeError, "Log.level= expects a valid LogLevel");
        Log::get_instance()->set_log_level(static_cast<LogLevel>(l));
        return self;
    }

    /*
     * call-seq:
     *     set_program_name(name)
     *
     * Set our program name.
     */
    VALUE
    log_set_program_name(VALUE self, VALUE name)
    {
        Log::get_instance()->set_program_name(stringify(StringValuePtr(name)));
        return self;
    }

    /*
     * call-seq:
     *     message(id, log_level, message)
     *
     * Log a message at the specified level.
     */
    VALUE
    log_message(VALUE self, VALUE id, VALUE log_level, VALUE message)
    {
        int l = NUM2INT(log_level);
        if (l < 0 || l >= last_ll)
            rb_raise(rb_eTypeError, "Log.log_message expects a valid LogLevel as the first parameter");
        Log::get_instance()->message(stringify(StringValuePtr(id)), static_cast<LogLevel>(l), lc_no_context)
            << stringify(StringValuePtr(message));
        return self;
    }

    void do_register_log()
    {
        rb_require("singleton");

        /*
         * Document-class: Paludis::Log
         *
         * Singleton class that handles log messages.
         */
        c_log = rb_define_class_under(c_paludis_module, "Log", rb_cObject);
        rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_log);
        rb_define_method(c_log, "log_level", log_log_level, 0);
        rb_define_method(c_log, "log_level=", log_log_level_set, 1);
        rb_define_method(c_log, "program_name=", log_set_program_name, 1);
        rb_define_method(c_log, "message", log_message, 3);

        /*
         * Document-module: Paludis::LogLevel
         *
         * Specifies the level of a log message
         */
        c_log_level = rb_define_module_under(c_paludis_module, "LogLevel");
        for (LogLevel l(static_cast<LogLevel>(0)), l_end(last_ll) ; l != l_end ;
                l = static_cast<LogLevel>(static_cast<int>(l) + 1))
            rb_define_const(c_log_level, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));

    }
}
message(id, log_level, message) click to toggle source

Log a message at the specified level.

VALUE
    log_message(VALUE self, VALUE id, VALUE log_level, VALUE message)
    {
        int l = NUM2INT(log_level);
        if (l < 0 || l >= last_ll)
            rb_raise(rb_eTypeError, "Log.log_message expects a valid LogLevel as the first parameter");
        Log::get_instance()->message(stringify(StringValuePtr(id)), static_cast<LogLevel>(l), lc_no_context)
            << stringify(StringValuePtr(message));
        return self;
    }

    void do_register_log()
    {
        rb_require("singleton");

        /*
         * Document-class: Paludis::Log
         *
         * Singleton class that handles log messages.
         */
        c_log = rb_define_class_under(c_paludis_module, "Log", rb_cObject);
        rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_log);
        rb_define_method(c_log, "log_level", log_log_level, 0);
        rb_define_method(c_log, "log_level=", log_log_level_set, 1);
        rb_define_method(c_log, "program_name=", log_set_program_name, 1);
        rb_define_method(c_log, "message", log_message, 3);

        /*
         * Document-module: Paludis::LogLevel
         *
         * Specifies the level of a log message
         */
        c_log_level = rb_define_module_under(c_paludis_module, "LogLevel");
        for (LogLevel l(static_cast<LogLevel>(0)), l_end(last_ll) ; l != l_end ;
                l = static_cast<LogLevel>(static_cast<int>(l) + 1))
            rb_define_const(c_log_level, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));

    }
}
set_program_name(name) click to toggle source

Set our program name.

VALUE
    log_set_program_name(VALUE self, VALUE name)
    {
        Log::get_instance()->set_program_name(stringify(StringValuePtr(name)));
        return self;
    }

    /*
     * call-seq:
     *     message(id, log_level, message)
     *
     * Log a message at the specified level.
     */
    VALUE
    log_message(VALUE self, VALUE id, VALUE log_level, VALUE message)
    {
        int l = NUM2INT(log_level);
        if (l < 0 || l >= last_ll)
            rb_raise(rb_eTypeError, "Log.log_message expects a valid LogLevel as the first parameter");
        Log::get_instance()->message(stringify(StringValuePtr(id)), static_cast<LogLevel>(l), lc_no_context)
            << stringify(StringValuePtr(message));
        return self;
    }

    void do_register_log()
    {
        rb_require("singleton");

        /*
         * Document-class: Paludis::Log
         *
         * Singleton class that handles log messages.
         */
        c_log = rb_define_class_under(c_paludis_module, "Log", rb_cObject);
        rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_log);
        rb_define_method(c_log, "log_level", log_log_level, 0);
        rb_define_method(c_log, "log_level=", log_log_level_set, 1);
        rb_define_method(c_log, "program_name=", log_set_program_name, 1);
        rb_define_method(c_log, "message", log_message, 3);

        /*
         * Document-module: Paludis::LogLevel
         *
         * Specifies the level of a log message
         */
        c_log_level = rb_define_module_under(c_paludis_module, "LogLevel");
        for (LogLevel l(static_cast<LogLevel>(0)), l_end(last_ll) ; l != l_end ;
                l = static_cast<LogLevel>(static_cast<int>(l) + 1))
            rb_define_const(c_log_level, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));

    }
}