annotate src/goodjava/logger/LevelAppender.java @ 1474:13cbce740e1e

LowercaseAnalyzer
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 17 Apr 2020 21:53:09 -0600
parents 85d7c1777357
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1449
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.logger;
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3
1451
Franklin Schmidt <fschmidt@gmail.com>
parents: 1449
diff changeset
4 public final class LevelAppender implements Appender {
1449
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 private final Appender appender;
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 private final int level;
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 public LevelAppender(Appender appender,int level) {
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 this.appender = appender;
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 this.level = level;
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 }
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 public void append(LoggingEvent event) {
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 if( event.level >= this.level )
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 appender.append(event);
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 }
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 public void close() {
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 appender.close();
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 }
dd14d2dce7ee add appenders
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 }