NETWORK ATTACKS FRAMEWORK  1.0.0
A NETwork Attacks framework. Making network attacks impact evaluation easier!
NA_NesgLog.h
Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2013, NESG (Network Engineering and Security Group), http://nesg.ugr.es,
00003 // - Gabriel Maciá Fernández (gmacia@ugr.es)
00004 // - Leovigildo Sánchez Casado (sancale@ugr.es)
00005 // - Rafael A. Rodríguez Gómez (rodgom@ugr.es)
00006 // - Roberto Magán Carrión (rmagan@ugr.es)
00007 // - Pedro García Teodoro (pgteodor@ugr.es)
00008 // - José Camacho Páez (josecamacho@ugr.es)
00009 // - Jesús E. Díaz Verdejo (jedv@ugr.es)
00010 //
00011 // This file is part of NETA.
00012 //
00013 //    NETA is free software: you can redistribute it and/or modify
00014 //    it under the terms of the GNU General Public License as published by
00015 //    the Free Software Foundation, either version 3 of the License, or
00016 //    (at your option) any later version.
00017 //
00018 //    NETA is distributed in the hope that it will be useful,
00019 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //    GNU General Public License for more details.
00022 //
00023 //    You should have received a copy of the GNU General Public License
00024 //    along with NETA.  If not, see <http://www.gnu.org/licenses/>.
00025 //
00026 
00027 #ifndef NESGLOG_H_
00028 #define NESGLOG_H_
00029 
00030 #include <fstream>
00031 #include <omnetpp.h>
00032 #include <stdarg.h>
00033 #include <NA_Utils.h>
00034 
00035 using namespace std;
00036 
00038 #define NESGLOGHEADER "[" << NA_Utils::currentDateTime() << "][" << simTime() << "][NESGLOG]: "
00039 
00040 #define LOG log << NESGLOGHEADER
00041 
00057 class NA_NesgLog {
00058 public:
00062     NA_NesgLog();
00063 
00067     ~NA_NesgLog() {
00068     }
00069 
00075     void write(const char* logline, ...);
00076 
00080     void unsetLog();
00081 
00088     NA_NesgLog& operator<<(const std::string& t) {
00089         if (active)
00090             EV << t;
00091         return *this;
00092     } // For strings
00093 
00100     template<typename T> NA_NesgLog& operator<<(const T& t) {
00101         if (active)
00102             EV << t;
00103         return *this;
00104     } // For generic objects
00105 
00112     NA_NesgLog& operator<<(std::ostream& (t)(std::ostream&)) {
00113         if (active)
00114             EV << t;
00115         return *this;
00116     } // For objects like endl
00117 
00118 private:
00122     bool active; // Indicates if logging is active or not
00123 
00124 };
00125 
00126 #endif
 All Classes Files Functions Variables Typedefs Enumerator Defines