servletcontextlog.java

来自「CroftSoft Code Library是一个开源的可移植的纯Java游戏库」· Java 代码 · 共 65 行

JAVA
65
字号
     package com.croftsoft.core.util.log;

     import javax.servlet.Servlet;
     import javax.servlet.ServletContext;

     import com.croftsoft.core.lang.NullArgumentException;

     /*********************************************************************
     * Delegates logging to a ServletContext.
     *
     * @author
     *   <A HREF="http://www.alumni.caltech.edu/~croft/">David W. Croft</A>
     * @version
     *   2001-02-27
     *********************************************************************/

     public final class  ServletContextLog implements Log
     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////
     {

     private final ServletContext  servletContext;

     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////

     public  ServletContextLog ( ServletContext  servletContext )
     //////////////////////////////////////////////////////////////////////
     {
       NullArgumentException.check (
         this.servletContext = servletContext );
     }

     public  ServletContextLog ( Servlet  servlet )
     //////////////////////////////////////////////////////////////////////
     {
       this ( servlet.getServletConfig ( ).getServletContext ( ) );
     }

     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////

     public void  record ( String  message )
     //////////////////////////////////////////////////////////////////////
     {
       servletContext.log ( message );
     }

     public void  record ( Throwable  throwable )
     //////////////////////////////////////////////////////////////////////
     {
       servletContext.log ( throwable.getMessage ( ), throwable );
     }


     public void  record ( String  message, Throwable  throwable )
     //////////////////////////////////////////////////////////////////////
     {
       servletContext.log ( message, throwable );
     }

     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////
     }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?