Click here to Skip to main content
15,895,084 members
Articles / Desktop Programming / MFC

LogXML - A XML Logging Class

Rate me:
Please Sign up or sign in to vote.
4.50/5 (13 votes)
11 May 20031 min read 93.8K   3K   39  
A simple XML style logging class for all purposes.
/*

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

                           LogXML 1.0
                       ------------------

  LogXML is a simple and free logging class for all purposes.
  You can use it freely und unlimited but give me credit
  where it's due.

  Source code is ready for DoxyGen (http://www.doxygen.org/).

  Written by Christian Richardt (cr@whizer.net).

  Release history:
    Mai 12, 2003: Version 1.0. First release.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*/

/**
  \file    LogXML.h
  \brief   XML log class
  \date    2003-05-12
  \author  Christian Richardt (cr@whizer.net)
**/

#ifndef LOGXML_H
#define LOGXML_H


  #include <stdio.h>



    /// base name of file
  char* FileName(char* strFile);

    /// UNIX timestamp: seconds from 1970-01-01 00:00:00 (UTC)
  double mtime(void);



    /**
      \brief   LogXML is a simple and free logging class for all purposes.
      \author  Christian Richardt (cr@whizer.net)
    **/
  class LogXML
   {
    public:
      LogXML(char* filename, char* appName="None");
      ~LogXML();

      bool  goDown(char* message=0, char* filename=0, char* funcname=0);
      void  goUp(void);

      bool  Log(char* message, char* filename=0, char* funcname=0);
      bool  WriteLine(char* data);
      bool  WriteLine(char* tagname, char* contents);
      bool  WriteTimestamp(void);
      bool  WriteDateTime(void);

    protected:
      bool  WriteData(char* data);

      char* m_strFilename; ///< log file name
      FILE* LogFile;       ///< file handle of log file
      int   Depth;         ///< current depth in document
   };


#endif // LOGXML_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions