Skip to content

Commit 10172e8

Browse files
committed
drop deprecated RackLogger string (level) constants
1 parent 05fcc73 commit 10172e8

8 files changed

+38
-46
lines changed

src/main/java/org/jruby/rack/AbstractRackDispatcher.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import java.io.IOException;
1111

12+
import static org.jruby.rack.RackLogger.Level.*;
13+
1214
/**
1315
*
1416
* @author nicksieger
@@ -46,10 +48,10 @@ protected void handleException(
4648
final RackResponseEnvironment response) throws IOException {
4749

4850
if ( response.isCommitted() ) {
49-
context.log(RackLogger.ERROR, "couldn't handle exception (response is committed)", e);
51+
context.log(ERROR, "couldn't handle exception (response is committed)", e);
5052
return;
5153
}
52-
context.log(RackLogger.INFO, "resetting rack response due exception: " + e);
54+
context.log(INFO, "resetting rack response due exception: " + e);
5355
response.reset();
5456

5557
afterException(request, e, response);

src/main/java/org/jruby/rack/DefaultErrorApplication.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
import org.jruby.Ruby;
3535

36+
import static org.jruby.rack.RackLogger.Level.*;
37+
3638
/**
3739
* Default error application if the Rack error application can not be setup or
3840
* "jruby.rack.error" handling is turned off (set to false).
@@ -117,7 +119,7 @@ public String getBody() {
117119
body = buildErrorBody();
118120
}
119121
catch (Exception e) {
120-
log(RackLogger.INFO, "failed building error body", e);
122+
log(INFO, "failed building error body", e);
121123
body = getError() == null ? "" : getError().toString();
122124
}
123125
}
@@ -149,11 +151,11 @@ public void respond(RackResponseEnvironment response) {
149151
defaultRespond(this, response);
150152
}
151153
catch (IOException e) {
152-
log(RackLogger.WARN, "could not write response body", e);
154+
log(WARN, "could not write response body", e);
153155
}
154156
}
155157

156-
private void log(String level, String message, Throwable e) {
158+
private void log(RackLogger.Level level, String message, Throwable e) {
157159
if ( context != null ) context.log(level, message, e);
158160
}
159161

src/main/java/org/jruby/rack/DefaultRackApplicationFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ private String resolveRackupScript() throws RackInitializationException {
565565
}
566566
catch (IOException ex) { /* won't happen */ }
567567

568-
rackContext.log(RackLogger.ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")");
568+
rackContext.log(ERROR, "failed to read rackup from '"+ rackup + "' (" + e + ")");
569569
throw new RackInitializationException("failed to read rackup input", e);
570570
}
571571
}

src/main/java/org/jruby/rack/DefaultRackDispatcher.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import org.jruby.rack.servlet.ServletRackContext;
1313

14+
import static org.jruby.rack.RackLogger.Level.*;
15+
1416
/**
1517
* Dispatcher suited for use in a servlet container
1618
* @author nick
@@ -50,10 +52,10 @@ protected void afterException(
5052
}
5153
catch (final RuntimeException re) {
5254
// allow the error app to re-throw Ruby/JRuby-Rack exceptions :
53-
if (re instanceof RackException) throw (RackException) re;
55+
if (re instanceof RackException) throw re;
5456
//if (e instanceof RaiseException) throw (RaiseException) e;
5557
// TODO seems redundant maybe we should let the container decide ?!
56-
context.log(RackLogger.ERROR, "error app failed to handle exception: " + e, re);
58+
context.log(ERROR, "error app failed to handle exception: " + e, re);
5759
Integer errorCode = getErrorApplicationFailureStatusCode();
5860
if ( errorCode != null && errorCode.intValue() > 0 ) {
5961
response.sendError(errorCode);

src/main/java/org/jruby/rack/RackLogger.java

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
* @author nicksieger
1313
*/
1414
public interface RackLogger {
15-
16-
void log(String message) ;
17-
void log(String message, Throwable ex) ;
18-
1915
//void debug(String message) ;
2016
//void debug(String message, Throwable e) ;
2117

@@ -37,44 +33,27 @@ enum Level {
3733
void log(Level level, String message) ;
3834
void log(Level level, String message, Throwable ex) ;
3935

40-
@Deprecated final String DEBUG = Level.DEBUG.name();
41-
@Deprecated final String INFO = Level.INFO.name();
42-
@Deprecated final String WARN = Level.WARN.name();
43-
@Deprecated final String ERROR = Level.ERROR.name();
36+
default void log(String message) {
37+
log(Level.INFO, message);
38+
}
4439

45-
void log(String level, String message) ;
46-
void log(String level, String message, Throwable ex) ;
40+
default void log(String message, Throwable ex) {
41+
log(Level.ERROR, message, ex);
42+
}
4743

48-
abstract class Base implements RackLogger {
44+
default void log(String level, String message) {
45+
log(Level.valueOf(level), message);
46+
}
4947

50-
public abstract Level getLevel() ;
48+
default void log(String level, String message, Throwable ex) {
49+
log(Level.valueOf(level), message, ex);
50+
}
5151

52+
abstract class Base implements RackLogger {
53+
public abstract Level getLevel() ;
5254
public void setLevel(Level level) { /* noop */ }
5355

5456
public boolean isFormatting() { return false; }
55-
5657
public void setFormatting(boolean flag) { /* noop */ }
57-
58-
@Override
59-
public void log(String message) {
60-
log(Level.INFO, message);
61-
}
62-
63-
@Override
64-
public void log(String message, Throwable ex) {
65-
log(Level.ERROR, message, ex);
66-
}
67-
68-
@Override
69-
public void log(String level, String message) {
70-
log(Level.valueOf(level), message);
71-
}
72-
73-
@Override
74-
public void log(String level, String message, Throwable ex) {
75-
log(Level.valueOf(level), message, ex);
76-
}
77-
7858
}
79-
8059
}

src/main/java/org/jruby/rack/RackServletContextListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.jruby.rack.servlet.ServletRackContext;
1717

1818
import static org.jruby.rack.DefaultRackConfig.isThrowInitException;
19+
import static org.jruby.rack.RackLogger.Level.*;
1920

2021
/**
2122
* Web application lifecycle listener.
@@ -94,7 +95,7 @@ protected void handleInitializationException(
9495
throw RackInitializationException.wrap(e);
9596
}
9697
// NOTE: factory should have already logged the error ...
97-
rackContext.log(RackLogger.ERROR, "initialization failed", e);
98+
rackContext.log(ERROR, "initialization failed", e);
9899
}
99100

100101
}

src/main/java/org/jruby/rack/servlet/DefaultServletRackContext.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
*
3636
* @author nicksieger
3737
*/
38-
@SuppressWarnings("rawtypes")
3938
public class DefaultServletRackContext implements ServletRackContext {
4039

4140
private final RackConfig config;

src/main/java/org/jruby/rack/servlet/ServletRackContext.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ public interface ServletRackContext extends RackContext, ServletContext {
2121

2222
RackApplicationFactory getRackFactory();
2323

24-
// ServletContext getRealContext(); // TODO support this in 1.2
24+
@Override
25+
default void log(String message) {
26+
RackContext.super.log(message);
27+
}
2528

29+
@Override
30+
default void log(String message, Throwable ex) {
31+
RackContext.super.log(message, ex);
32+
}
2633
}

0 commit comments

Comments
 (0)