KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > log > TraceLogHandler


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: TraceLogHandler.java,v 1.30 2006/10/30 21:14:21 bostic Exp $
7  */

8
9 package com.sleepycat.je.log;
10
11 import java.util.logging.Handler JavaDoc;
12 import java.util.logging.LogRecord JavaDoc;
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 JavaDoc {
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 JavaDoc l) {
37         if (!env.isReadOnly() &&
38         !env.mayNotWrite()) {
39             try {
40                 Tracer newRec = new Tracer(l.getMessage());
41                 env.getLogManager().log(newRec);
42             } catch (DatabaseException e) {
43                 /* Eat exception. */
44                 System.err.println("Problem seen while tracing into " +
45                                    "the database log:");
46                 e.printStackTrace();
47             }
48         }
49     }
50 }
51
Popular Tags