Skip to content
Snippets Groups Projects
Logging.hpp 1.78 KiB
Newer Older
/*
  Copyright (C) 2019-2020 CERN for the benefit of the FASER collaboration
*/

///////////////////////////////////////////////////////////////////
// Logging.hpp, (c) FASER Detector software
///////////////////////////////////////////////////////////////////

Brian Petersen's avatar
Brian Petersen committed
//============================================================================
// Name        : SimpleLogger
// Author      : Sam Meehan
// Version     : v0.0
// Copyright   : Your copyright notice
// Description : This is not really a "logger" per say but a template that allows you
//               to print descriptive debugging information to the screen using the same
//               function templates as is used in a real logger like in daqling
//============================================================================

#include <stdio.h>
#include <iostream>
#include <iomanip>

Jens Noerby Kristensen's avatar
Jens Noerby Kristensen committed
#ifdef DAQLING_LOGGING
  #pragma message "Compiled with DAQling logger"
  #include "Utils/Ers.hpp"
#else
#ifndef ERS_HPP
//Check if logging macros already defined.
Brian Petersen's avatar
Brian Petersen committed
#pragma message "Compiled without DAQling logger"

// Base log output - just printing to screen
#define LOG(LEVEL,MSG) std::cout << "[" << LEVEL <<"] " \
                                 <<"(file = "<<std::left<<__FILE__<<")" \
                                 <<"(func = "<<std::left<<__FUNCTION__<<")" \
                                 <<"(line = "<<std::left<<__LINE__<<")" \
                                 <<" | "<< MSG << std::endl; \
Brian Petersen's avatar
Brian Petersen committed

// Log levels
#define TRACE(MSG)    LOG("TRACE", MSG)
#define DEBUG(MSG)    LOG("DEBUG", MSG)
#define INFO(MSG)     LOG("INFO", MSG)
#define WARNING(MSG)  LOG("WARNING", MSG)
#define ERROR(MSG)    LOG("ERROR", MSG)
Jens Noerby Kristensen's avatar
Jens Noerby Kristensen committed
#define FATAL(MSG) LOG("FATAL", MSG)
Brian Petersen's avatar
Brian Petersen committed

// Level aliases
#define NOTICE(MSG)   LOG("NOTICE", MSG)
#define ALERT(MSG)    LOG("ALERT", MSG)
Jens Noerby Kristensen's avatar
Jens Noerby Kristensen committed
#endif
#endif