001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.log4j.chainsaw; 018 019import org.apache.log4j.Priority; 020import org.apache.log4j.spi.LoggingEvent; 021 022/** 023 * Represents the details of a logging event. It is intended to overcome the 024 * problem that a LoggingEvent cannot be constructed with purely fake data. 025 * 026 * @author <a href="mailto:oliver@puppycrawl.com">Oliver Burn</a> 027 * @version 1.0 028 */ 029class EventDetails { 030 031 /** the time of the event **/ 032 private final long mTimeStamp; 033 /** the priority of the event **/ 034 private final Priority mPriority; 035 /** the category of the event **/ 036 private final String mCategoryName; 037 /** the NDC for the event **/ 038 private final String mNDC; 039 /** the thread for the event **/ 040 private final String mThreadName; 041 /** the msg for the event **/ 042 private final String mMessage; 043 /** the throwable details the event **/ 044 private final String[] mThrowableStrRep; 045 /** the location details for the event **/ 046 private final String mLocationDetails; 047 048 /** 049 * Creates a new <code>EventDetails</code> instance. 050 * @param aTimeStamp a <code>long</code> value 051 * @param aPriority a <code>Priority</code> value 052 * @param aCategoryName a <code>String</code> value 053 * @param aNDC a <code>String</code> value 054 * @param aThreadName a <code>String</code> value 055 * @param aMessage a <code>String</code> value 056 * @param aThrowableStrRep a <code>String[]</code> value 057 * @param aLocationDetails a <code>String</code> value 058 */ 059 EventDetails(long aTimeStamp, 060 Priority aPriority, 061 String aCategoryName, 062 String aNDC, 063 String aThreadName, 064 String aMessage, 065 String[] aThrowableStrRep, 066 String aLocationDetails) 067 { 068 mTimeStamp = aTimeStamp; 069 mPriority = aPriority; 070 mCategoryName = aCategoryName; 071 mNDC = aNDC; 072 mThreadName = aThreadName; 073 mMessage = aMessage; 074 mThrowableStrRep = aThrowableStrRep; 075 mLocationDetails = aLocationDetails; 076 } 077 078 /** 079 * Creates a new <code>EventDetails</code> instance. 080 * 081 * @param aEvent a <code>LoggingEvent</code> value 082 */ 083 EventDetails(LoggingEvent aEvent) { 084 085 this(aEvent.timeStamp, 086 aEvent.getLevel(), 087 aEvent.getLoggerName(), 088 aEvent.getNDC(), 089 aEvent.getThreadName(), 090 aEvent.getRenderedMessage(), 091 aEvent.getThrowableStrRep(), 092 (aEvent.getLocationInformation() == null) 093 ? null : aEvent.getLocationInformation().fullInfo); 094 } 095 096 /** @see #mTimeStamp **/ 097 long getTimeStamp() { 098 return mTimeStamp; 099 } 100 101 /** @see #mPriority **/ 102 Priority getPriority() { 103 return mPriority; 104 } 105 106 /** @see #mCategoryName **/ 107 String getCategoryName() { 108 return mCategoryName; 109 } 110 111 /** @see #mNDC **/ 112 String getNDC() { 113 return mNDC; 114 } 115 116 /** @see #mThreadName **/ 117 String getThreadName() { 118 return mThreadName; 119 } 120 121 /** @see #mMessage **/ 122 String getMessage() { 123 return mMessage; 124 } 125 126 /** @see #mLocationDetails **/ 127 String getLocationDetails(){ 128 return mLocationDetails; 129 } 130 131 /** @see #mThrowableStrRep **/ 132 String[] getThrowableStrRep() { 133 return mThrowableStrRep; 134 } 135}