Home | History | Annotate | Download | only in src
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 #ifndef TEST_PV_AUTHOR_ENGINE_LOGGER_H_INCLUDED
     19 #define TEST_PV_AUTHOR_ENGINE_LOGGER_H_INCLUDED
     20 
     21 #ifndef OSCL_TYPES_H_INCLUDED
     22 #include "oscl_types.h"
     23 #endif
     24 
     25 #ifndef OSCL_DEFALLOC_H_INCLUDED
     26 #include "oscl_defalloc.h"
     27 #endif
     28 
     29 //===================================================================
     30 //CLASS:       PVAELOGGER
     31 //===================================================================
     32 // Initialize logging nodes
     33 //===================================================================
     34 // Format of logging configuration file:
     35 // A hash mark (#) is used to indicate a comment line which will not
     36 // be parsed.
     37 // First line can be NO_LOGGING in which case no logs are created
     38 // and the rest of the file is skipped
     39 // By default logging output is directed to stderr (non-Windows) or
     40 // ATL Trace (Win32/WinMobile). If LOGTOFILE is specified on the first
     41 // line, output is redirected into a new file PVAUTHORLOG.TXT using a
     42 // text file appender. If LOGTOMEM is specified on the first line,
     43 // the output is still redirected to the file PVAUTHORLOG.TXT but using
     44 // a memory appender.
     45 // All other lines must be of the format NODENAME;LOGLEVEL where
     46 // nodename is the case-sensitive name of a node such as EngineHandler
     47 // or PVPlayer. Use ALLNODES if you want all nodes to be logged.
     48 // LOGLEVEL is one of :
     49 // PVLOGMSG_EMERG
     50 // PVLOGMSG_ALERT
     51 // PVLOGMSG_CRIT
     52 // PVLOGMSG_ERR
     53 // PVLOGMSG_WARNING
     54 // PVLOGMSG_NOTICE
     55 // PVLOGMSG_INFO
     56 // PVLOGMSG_STACK_TRACE
     57 //===================================================================
     58 // Example:
     59 //
     60 // # This is a sample configuration
     61 // LOGTOFILE
     62 // PVAuthorEngine;PVLOGMSG_DEBUG
     63 // PVAuthorEngine;PVLOGMSG_WARNING
     64 
     65 class PVAELogger
     66 {
     67     public:
     68         // Open pwszConfigFile to read nodes (and levels) to log
     69         // Returns true on success
     70         OSCL_IMPORT_REF static bool ParseConfigFile(const oscl_wchar *pwszConfigFile);
     71 
     72         // Attach a StdErrAppender to "PVAtuhorEngine" at level PVLOGMSG_DEBUG
     73         // Returns true on success
     74         OSCL_IMPORT_REF static bool MakeStdErrAppender();
     75 
     76         OSCL_EXPORT_REF static int32 CreateTestAppender(char *aBuf, PVLoggerAppender *&aAppender, OsclRefCounter *&aRefCounter, OsclSharedPtr<PVLoggerAppender> &aSharedAppenderPtr);
     77 };
     78 
     79 //===================================================================
     80 //CLASS:       LogAppenderDestructDealloc
     81 //===================================================================
     82 // For smart ptrs call delete when done (used by LogAppender)
     83 template<class DestructClass>
     84 class LogAppenderDestructDealloc : public OsclDestructDealloc
     85 {
     86     public:
     87         virtual void destruct_and_dealloc(OsclAny *ptr)
     88         {
     89             delete((DestructClass*)ptr);
     90         }
     91 };
     92 
     93 
     94 #endif //TEST_PV_AUTHOR_ENGINE_LOGGER_H_INCLUDED
     95