aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-25 22:10:04 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-25 22:10:04 +0000
commit98a6becac52ccf6508ab284adaaad83929dd65c5 (patch)
treed55cbd8928965942cd6d0811b50006444d55b8a7
parent75615b91e37d7148461f988c5eab2fb214a62b85 (diff)
downloadpaludis-98a6becac52ccf6508ab284adaaad83929dd65c5.tar.gz
paludis-98a6becac52ccf6508ab284adaaad83929dd65c5.tar.xz
Allow Log::program_name=. From Richard Brown
-rw-r--r--ruby/demos/find_unused_distfiles.rb1
-rw-r--r--ruby/demos/version_spec_distributions.rb1
-rw-r--r--ruby/log.cc8
-rw-r--r--ruby/log_TEST.rb12
4 files changed, 22 insertions, 0 deletions
diff --git a/ruby/demos/find_unused_distfiles.rb b/ruby/demos/find_unused_distfiles.rb
index f7f7714..6fcc6cc 100644
--- a/ruby/demos/find_unused_distfiles.rb
+++ b/ruby/demos/find_unused_distfiles.rb
@@ -5,6 +5,7 @@ require 'Paludis'
require 'getoptlong'
Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
+Paludis::Log.instance.program_name = $0
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
diff --git a/ruby/demos/version_spec_distributions.rb b/ruby/demos/version_spec_distributions.rb
index 6de4568..1a30249 100644
--- a/ruby/demos/version_spec_distributions.rb
+++ b/ruby/demos/version_spec_distributions.rb
@@ -5,6 +5,7 @@ require 'Paludis'
require 'getoptlong'
Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
+Paludis::Log.instance.program_name = $0
class Distribution
def initialize
diff --git a/ruby/log.cc b/ruby/log.cc
index 1dd9abb..0c50a3e 100644
--- a/ruby/log.cc
+++ b/ruby/log.cc
@@ -45,6 +45,13 @@ namespace
}
VALUE
+ log_set_program_name(VALUE self, VALUE name)
+ {
+ Log::get_instance()->set_program_name(stringify(STR2CSTR(name)));
+ return self;
+ }
+
+ VALUE
log_message(VALUE self, VALUE log_level, VALUE message)
{
Log::get_instance()->message(static_cast<LogLevel>(NUM2INT(log_level)), lc_no_context,
@@ -60,6 +67,7 @@ namespace
rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_log);
rb_define_method(c_log, "log_level", RUBY_FUNC_CAST(&log_log_level), 0);
rb_define_method(c_log, "log_level=", RUBY_FUNC_CAST(&log_log_level_set), 1);
+ rb_define_method(c_log, "program_name=", RUBY_FUNC_CAST(&log_set_program_name), 1);
rb_define_method(c_log, "message", RUBY_FUNC_CAST(&log_message), 2);
c_log_level = rb_define_class_under(master_class(), "LogLevel", rb_cObject);
diff --git a/ruby/log_TEST.rb b/ruby/log_TEST.rb
index f745594..0657cbb 100644
--- a/ruby/log_TEST.rb
+++ b/ruby/log_TEST.rb
@@ -34,6 +34,18 @@ class Paludis
x = Log.new()
end
end
+
+ def test_set_program_name
+ assert_nothing_raised do
+ Log.instance.program_name = 'TestProg'
+ end
+ end
+
+ def test_no_set_program_name
+ assert_raise TypeError do
+ Log.instance.program_name = 7
+ end
+ end
end
class TestCase_LogLogLevel < Test::Unit::TestCase