Skip to content

Commit

Permalink
Expose logger::write to Ruby.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed May 1, 2015
1 parent 91cf758 commit 7c31733
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kernel/bootstrap/logger.rb
Expand Up @@ -49,6 +49,11 @@ def initialize(name)
@format = "#{name}: %s"
end

def write(message)
Rubinius.primitive :logger_write
raise PrimitiveFailure, "Rubinius::Logger#write primitive failed"
end

def fatal(message)
Rubinius.primitive :logger_fatal
raise PrimitiveFailure, "Rubinius::Logger#fatal primitive failed"
Expand Down
5 changes: 5 additions & 0 deletions vm/builtin/logger.cpp
Expand Up @@ -25,6 +25,11 @@ namespace rubinius {
return logger;
}

Object* Logger::write(STATE, String* message) {
logger::write(format()->c_str(state), message->c_str(state));
return cNil;
}

Object* Logger::fatal(STATE, String* message) {
logger::fatal(format()->c_str(state), message->c_str(state));
return cNil;
Expand Down
3 changes: 3 additions & 0 deletions vm/builtin/logger.hpp
Expand Up @@ -27,6 +27,9 @@ namespace rubinius {
// Rubinius.primitive+ :logger_allocate
static Logger* allocate(STATE, Object* self);

// Rubinius.primitive :logger_write
Object* write(STATE, String* message);

// Rubinius.primitive :logger_fatal
Object* fatal(STATE, String* message);

Expand Down

0 comments on commit 7c31733

Please sign in to comment.