Skip to content
Snippets Groups Projects
Select Git revision
  • 108-implement-cpu-id-query-for-apple-m1-hardware
  • devel default
  • 107-compilation-error-when-building-maestro-core-on-m1-apple-processors
  • 58-scripting-interface-to-maestro-core
  • 101-need-ci-test-using-installed-maestro
  • 57-sphinx-documentation
  • 105-memory-leak-in-pm-message-envelope-handling
  • 104-permit-disabling-memory-pool
  • 103-liberl-installation-issue-on-devel
  • 94-maestro-rdma-transport-ignores-max_msg_size-2
  • main protected
  • 102-possible-race-in-check_pm_redundant_interlock-test
  • 97-check-if-shm-provider-can-be-enabled-after-libfabric-1-14-is-in-our-tree-2
  • 100-include-maestro-attributes-h-cannot-include-mamba-header-from-deps-path
  • 97-check-if-shm-provider-can-be-enabled-after-libfabric-1-14-is-in-our-tree
  • 17-job-failed-282354-needs-update-of-mio-interface-and-build-rules
  • 96-test-libfabric-update-to-1-13-or-1-14
  • feature/stop-telemetry-after-all-left
  • 94-maestro-rdma-transport-ignores-max_msg_size
  • 93-improve-performance-of-mstro_attribute_val_cmp_str
  • v0.3_rc1
  • maestro_d65
  • d65_experiments_20211113
  • v0.2
  • v0.2_rc1
  • d3.3
  • d3.3-review
  • d5.5
  • d5.5-review
  • v0.1
  • d3.2
  • d3.2-draft
  • v0.0
33 results

README.md

Blame
  • Debug.cpp 2.77 KiB
    /**
    * @file Debug.cpp
    * @author   Ulrich Kemloh <kemlohulrich@gmail.com>
    * @version 0.1
    * Copyright (C) <2009-2010>
    *
    * @section LICENSE
    * This file is part of OpenPedSim.
    *
    * OpenPedSim 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
    * any later version.
    *
    * OpenPedSim 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 OpenPedSim. If not, see <http://www.gnu.org/licenses/>.
    *
    * @section DESCRIPTION
    *
    * \brief This class defines a debug output with different debug levels (similar to python).
    * The message sent to the output are printed or not depending on the debug level set.
    *
    *
    *  Created on: 31.04.2010
    *
    */
    
    
    #include "Debug.h"
    
    #include <fstream>
    #include <iostream>
    
    #include <stdio.h>
    #include <stdarg.h>
    
    using namespace std;
    
    std::ostream& Debug::os=std::cerr;
    Debug::LEVEL Debug::debugLevel=Debug::ERROR;
    int Debug::MSG_Count=0;
    int Debug::ERR_Count=0;
    int Debug::WAR_Count=0;
    
    Debug::Debug()
    {
    
    }
    
    Debug::~Debug()
    {
    
    }
    
    
    void Debug::setOutputStream(std::ostream &osl )
    {
        os.rdbuf(osl.rdbuf());
    }
    
    void Debug::setDebugLevel(Debug::LEVEL level)
    {
        debugLevel=level;
    }
    
    void Debug::Messages(const char *format, ...)
    {
    
        switch (debugLevel) {
    
        case ALL:
        case INFO: {
            MSG_Count++;
            char msg[256];
            va_list ap;
            va_start (ap, format);
            vsprintf (msg,format ,ap);
            va_end (ap);
    
            os<<"Info["<<MSG_Count<<"]"<<msg<<endl;
        }
        break;
    
        case ERROR:
        case WARNING:
        case NONE:
            break;
        }
    
    }
    
    void Debug::Warning(const char *format, ...)
    {
    
        switch (debugLevel) {
    
        case WARNING:
        case ALL: {
            WAR_Count++;
            char msg[256];
            va_list ap;
            va_start (ap, format);
            vsprintf (msg,format ,ap);
            va_end (ap);
            os<<"Warning["<<WAR_Count<<"]"<<msg<<endl;
        }
        break;
    
        case ERROR:
        case INFO:
        case NONE:
            break;
        }
    }
    
    
    void Debug::Error(const char *format, ...)
    {
    
        switch (debugLevel) {
    
        case WARNING:
        case ERROR :
        case ALL: {
            ERR_Count++;
            char msg[256];
            va_list ap;
            va_start (ap, format);
            vsprintf (msg,format ,ap);
            va_end (ap);
            os<<"Error["<<ERR_Count<<"]"<<msg<<endl;
        }
        break;
    
        case INFO:
        case NONE:
            break;
        }
    
    }