Advertisement
mnaufaldillah

LogEvent Jmeter

Oct 23rd, 2021
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.28 KB | None | 0 0
  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to you under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  * http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17.  
  18. package org.apache.log;
  19.  
  20. import java.io.ObjectStreamException;
  21. import java.io.Serializable;
  22.  
  23. /**
  24.  * This class encapsulates each individual log event.
  25.  * LogEvents usually originate at a Logger and are routed
  26.  * to LogTargets.
  27.  *
  28.  * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  29.  * @author Peter Donald
  30.  * @deprecated Will be dropped in 3.3
  31.  */
  32. @Deprecated
  33. public final class LogEvent
  34.     implements Serializable
  35. {
  36.     private static final long serialVersionUID = 1L;
  37.  
  38.     //A Constant used when retrieving time relative to start of application start
  39.     private static final long START_TIME = System.currentTimeMillis();
  40.  
  41.     ///The category that this LogEvent concerns. (Must not be null)
  42.     private String m_category;
  43.  
  44.     ///The message to be logged. (Must not be null)
  45.     private String m_message;
  46.  
  47.     ///The exception that caused LogEvent if any. (May be null)
  48.     private Throwable m_throwable;
  49.  
  50.     ///The time in millis that LogEvent occurred
  51.     private long m_time;
  52.  
  53.     ///The priority of LogEvent. (Must not be null)
  54.     private Priority m_priority;
  55.  
  56.     ///The context map associated with LogEvent. (May be null).
  57.     private ContextMap m_contextMap;
  58.  
  59.     /**
  60.      * Get Priority for LogEvent.
  61.      *
  62.      * @return the LogEvent Priority
  63.      */
  64.     public final Priority getPriority()
  65.     {
  66.         return m_priority;
  67.     }
  68.  
  69.     /**
  70.      * Set the priority of LogEvent.
  71.      *
  72.      * @param priority the new LogEvent priority
  73.      */
  74.     public final void setPriority( final Priority priority )
  75.     {
  76.         m_priority = priority;
  77.     }
  78.  
  79.     /**
  80.      * Get ContextMap associated with LogEvent
  81.      *
  82.      * @return the ContextMap
  83.      */
  84.     public final ContextMap getContextMap()
  85.     {
  86.         return m_contextMap;
  87.     }
  88.  
  89.     /**
  90.      * Set the ContextMap for this LogEvent.
  91.      *
  92.      * @param contextMap the context map
  93.      */
  94.     public final void setContextMap( final ContextMap contextMap )
  95.     {
  96.         m_contextMap = contextMap;
  97.     }
  98.  
  99.     /**
  100.      * Get the category that LogEvent relates to.
  101.      *
  102.      * @return the name of category
  103.      */
  104.     public final String getCategory()
  105.     {
  106.         return m_category;
  107.     }
  108.  
  109.     /**
  110.      * Get the message associated with event.
  111.      *
  112.      * @return the message
  113.      */
  114.     public final String getMessage()
  115.     {
  116.         return m_message;
  117.     }
  118.  
  119.     /**
  120.      * Get throwable instance associated with event.
  121.      *
  122.      * @return the Throwable
  123.      */
  124.     public final Throwable getThrowable()
  125.     {
  126.         return m_throwable;
  127.     }
  128.  
  129.     /**
  130.      * Get the absolute time of the log event.
  131.      *
  132.      * @return the absolute time
  133.      */
  134.     public final long getTime()
  135.     {
  136.         return m_time;
  137.     }
  138.  
  139.     /**
  140.      * Get the time of the log event relative to start of application.
  141.      *
  142.      * @return the time
  143.      */
  144.     public final long getRelativeTime()
  145.     {
  146.         return m_time - START_TIME;
  147.     }
  148.  
  149.     /**
  150.      * Set the LogEvent category.
  151.      *
  152.      * @param category the category
  153.      */
  154.     public final void setCategory( final String category )
  155.     {
  156.         m_category = category;
  157.     }
  158.  
  159.     /**
  160.      * Set the message for LogEvent.
  161.      *
  162.      * @param message the message
  163.      */
  164.     public final void setMessage( final String message )
  165.     {
  166.         m_message = message;
  167.     }
  168.  
  169.     /**
  170.      * Set the throwable for LogEvent.
  171.      *
  172.      * @param throwable the instance of Throwable
  173.      */
  174.     public final void setThrowable( final Throwable throwable )
  175.     {
  176.         m_throwable = throwable;
  177.     }
  178.  
  179.     /**
  180.      * Set the absolute time of LogEvent.
  181.      *
  182.      * @param time the time
  183.      */
  184.     public final void setTime( final long time )
  185.     {
  186.         m_time = time;
  187.     }
  188.  
  189.     /**
  190.      * Helper method that replaces deserialized priority with correct singleton.
  191.      *
  192.      * @return the singleton version of object
  193.      * @exception ObjectStreamException if an error occurs
  194.      */
  195.     private Object readResolve()
  196.         throws ObjectStreamException
  197.     {
  198.         if( null == m_category )
  199.         {
  200.             m_category = "";
  201.         }
  202.         if( null == m_message )
  203.         {
  204.             m_message = "";
  205.         }
  206.  
  207.         String priorityName = "";
  208.         if( null != m_priority )
  209.         {
  210.             priorityName = m_priority.getName();
  211.         }
  212.  
  213.         m_priority = Priority.getPriorityForName( priorityName );
  214.  
  215.         return this;
  216.     }
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement