01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.rewriter.services.idsame;
06:
07: import java.util.logging.Handler;
08: import java.util.logging.Level;
09: import java.util.logging.LogRecord;
10:
11: public class IDSAMELogHandler extends Handler {
12: private final com.iplanet.am.util.Debug idsameHandler;
13:
14: public IDSAMELogHandler(final String aFileName) {
15: idsameHandler = com.iplanet.am.util.Debug
16: .getInstance(aFileName);
17: }//constructor
18:
19: public void publish(LogRecord aLogRecord) {
20: Level lLevel = aLogRecord.getLevel();
21: Throwable lExpection = aLogRecord.getThrown();
22: if (lExpection == null) {
23: if (lLevel == Level.FINEST) {
24: idsameHandler.message(aLogRecord.getMessage());
25: } else if (lLevel == Level.WARNING) {
26: idsameHandler.warning(aLogRecord.getMessage());
27: } else if (lLevel == Level.SEVERE) {
28: idsameHandler.error(aLogRecord.getMessage());
29: }
30: } else {
31: if (lLevel == Level.FINEST) {
32: idsameHandler.message(aLogRecord.getMessage(),
33: lExpection);
34: } else if (lLevel == Level.WARNING) {
35: idsameHandler.warning(aLogRecord.getMessage(),
36: lExpection);
37: } else if (lLevel == Level.SEVERE) {
38: idsameHandler
39: .error(aLogRecord.getMessage(), lExpection);
40: }
41: }
42: }//publish()
43:
44: public void flush() {
45: }//flush()
46:
47: public void close() throws SecurityException {
48: idsameHandler.destroy();
49: }//close()
50:
51: public Level getLevel() {
52: if (idsameHandler.messageEnabled()) {
53: return Level.FINEST;
54: } else if (idsameHandler.warningEnabled()) {
55: return Level.WARNING;
56: } else if (idsameHandler.getState() == idsameHandler.ERROR ? true
57: : false) {
58: return Level.SEVERE;
59: } else if (idsameHandler.getState() == idsameHandler.OFF ? true
60: : false) {
61: return Level.OFF;
62: }
63:
64: return super .getLevel();
65: }//getLevel()
66:
67: }//class IDSAMELogHandler
|