// =========================================================================== // // Filename: logging.h // // Description: Simple logging class. // // Version: 0.0 // Created: 09/12/2013 03:23:30 PM // Revision: none // Compiler: Tested with g++ // // Author: M. Andy Kass (MAK) // // Organisation: US Geological Survey // // // Email: mkass@usgs.gov // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // =========================================================================== #ifndef __logging_h #define __logging_h #include "formalhaut.h" #include "exceptions.h" #include namespace formalhaut { // =================================================================== // Class: Logging /// \brief /// \details // =================================================================== class Logging { friend std::ostream &operator<<(std::ostream &stream, const Logging &ob); public: // ==================== LIFECYCLE ======================= static Logging* New(); void Delete(); // ==================== OPERATORS ======================= // ==================== OPERATIONS ======================= /// Close the log file void CloseLogFile(); /// Write a single line to the log file void WriteLogLine(const std::string line); /// Write header information in the logger void WriteHeader(const std::string& name,const std::string& ver); /// Get current date and time, formatted std::string GetDateTime(); /// Write successful completion void WriteCloser(); /// Write a long dashed line void WriteDashedLine(); // ==================== ACCESS ======================= /// Set and open the log file void SetLogFile(const std::string& fname); // ==================== INQUIRY ======================= std::string GetLogFile(); protected: // ==================== LIFECYCLE ======================= /// Default protected constructor. Logging (); /// Default protected constructor. ~Logging (); // ==================== DATA MEMBERS ========================= // Log file name std::string LogFile; // File object std::ofstream outfile; private: }; // ----- end of class Logging ----- } // end of namespace #endif