01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: TraceLogHandler.java,v 1.31.2.3 2008/01/07 15:14:13 cwl Exp $
07: */
08:
09: package com.sleepycat.je.log;
10:
11: import java.util.logging.Handler;
12: import java.util.logging.LogRecord;
13:
14: import com.sleepycat.je.DatabaseException;
15: import com.sleepycat.je.dbi.EnvironmentImpl;
16: import com.sleepycat.je.utilint.Tracer;
17:
18: /**
19: * Handler for java.util.logging. Takes logging records and publishes them into
20: * the database log.
21: */
22: public class TraceLogHandler extends Handler {
23:
24: private EnvironmentImpl env;
25:
26: public TraceLogHandler(EnvironmentImpl env) {
27: this .env = env;
28: }
29:
30: public void close() {
31: }
32:
33: public void flush() {
34: }
35:
36: public void publish(LogRecord l) {
37: if (!env.isReadOnly() && !env.mayNotWrite()) {
38: try {
39: Tracer trace = new Tracer(l.getMessage());
40: trace.log(env.getLogManager());
41: } catch (DatabaseException e) {
42: throw new IllegalStateException(e);
43: }
44: }
45: }
46: }
|