Skip to content

Commit

Permalink
Add zero-argument versions of logger methods
Browse files Browse the repository at this point in the history
The add method already handled nil msg, but the main level methods
strictly required an argument.
  • Loading branch information
headius committed Jun 3, 2024
1 parent 7517b82 commit faaabb6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/org/jruby/rack/ext/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ public IRubyObject info(final ThreadContext context,
return context.runtime.newBoolean( add(INFO, context, msg, block) );
}

@JRubyMethod(name = "info")
public IRubyObject info(final ThreadContext context, final Block block) {
return info(context, context.nil, block);
}

//
// Log a +WARN+ message.
//
Expand All @@ -299,6 +304,11 @@ public IRubyObject warn(final ThreadContext context,
return context.runtime.newBoolean( add(WARN, context, msg, block) );
}

@JRubyMethod(name = "warn")
public IRubyObject warn(final ThreadContext context, final Block block) {
return warn(context, context.nil, block);
}

//
// Log a +ERROR+ message.
//
Expand All @@ -308,6 +318,11 @@ public IRubyObject error(final ThreadContext context,
return context.runtime.newBoolean( add(ERROR, context, msg, block) );
}

@JRubyMethod(name = "error")
public IRubyObject error(final ThreadContext context, final Block block) {
return error(context, context.nil, block);
}

//
// Log a +FATAL+ message.
//
Expand All @@ -317,6 +332,11 @@ public IRubyObject fatal(final ThreadContext context,
return context.runtime.newBoolean( add(FATAL, context, msg, block) );
}

@JRubyMethod(name = "fatal")
public IRubyObject fatal(final ThreadContext context, final Block block) {
return fatal(context, context.nil, block);
}

//
// Log an +UNKNOWN+ message.
// This will be printed no matter what the logger's level is.
Expand All @@ -328,6 +348,11 @@ public IRubyObject unknown(final ThreadContext context,
return context.runtime.newBoolean( add(UNKNOWN, context, msg, block) );
}

@JRubyMethod(name = "unknown")
public IRubyObject unknown(final ThreadContext context, final Block block) {
return unknown(context, context.nil, block);
}

// def add(severity, message = nil, progname = nil, &block)
@JRubyMethod(name = "add", required = 1, optional = 2)
public IRubyObject add(final ThreadContext context,
Expand Down

0 comments on commit faaabb6

Please sign in to comment.