<commit_before>#ifndef logging_macros_H
#define logging_macros_H
/*******************************************************************************
* ALMA - Atacama Large Millimiter Array
* (c) UNSPECIFIED - FILL IN, 2005
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*
* "@(#) $Id: loggingMACROS.h,v 1.22 2009/03/11 10:01:00 bjeram Exp $"
*
* who       when      what
* --------  --------  ----------------------------------------------
* dfugate  2005-04-04  created
*/

#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif

#include "loggingLogger.h"
#include "loggingLogTrace.h"
#include "loggingGetLogger.h"
#include <iostream>
#include <acsutilTimeStamp.h>

/**
 * Used to send logs. This macro is primarily useful because it automatically
 * determines the file name and line number for the developer. It is important
 * to note that getLogger() is defined in a header file other than what's included
 * above. UPDATE: I just included the file, don't know why it wasn't included before.
 * @param priority Logging::BaseLog::Priority of the log message
 * @param routine Name of the routine in which this macro is being used from (std::string)
 * @param text Log message (std::string)
 */
#define LOG(priority, routine, text) \
if (getLogger()!=0) \
{ \
  getLogger()->log(priority, text, __FILE__, __LINE__, routine); \
} \
else \
{ \
  std::cerr << "SEVERE LOGGING ERROR - getLogger() returned NULL: file="; \
  std::cerr << __FILE__ << ", line=" << __LINE__ << std::endl; \
}


/**
 * Used to send logs. This macro is primarily useful because it automatically
 * determines the file name and line number for the developer.
 * @param logPriority Logging::BaseLog::Priority of the log message
 * @param logRoutine Name of the routine in which this macro is being used from (std::string)
 * @param logMessage Log message (std::string)
 * @param logAudience intended receiver of this log message
 * @param logArray array where the log was generated
 * @param logAntenna antenna where the log was generated
 */
#define LOG_FULL(logPriority, logRoutine, logMessage, logAudience, logArray, logAntenna) \
if (getLogger()!=0) \
{ \
    Logging::BaseLog::LogRecord lr; \
    lr.priority  = Logging::ace2acsPriority(logPriority); \
    lr.message   = logMessage; \
    lr.file      = __FILE__; \
    lr.line      = __LINE__; \
    lr.method    = logRoutine; \
    lr.timeStamp = getTimeStamp(); \
    LoggingProxy::audience(logAudience); \
    LoggingProxy::array(logArray); \
    LoggingProxy::antenna(logAntenna); \
    LoggingProxy::Flags(LM_SOURCE_INFO | LM_RUNTIME_CONTEXT); \
    getLogger()->log(lr); \
} \
else \
{ \
  std::cerr << "SEVERE LOGGING ERROR - getLogger() returned NULL: file="; \
  std::cerr << __FILE__ << ", line=" << __LINE__ << std::endl; \
}

/**
 * Used to send logs. This macro is primarily useful because it automatically
 * determines the file name and line number for the developer.
 * @param logPriority Logging::BaseLog::Priority of the log message
 * @param logRoutine Name of the routine in which this macro is being used from (std::string)
 * @param logMessage Log message (std::string)
 * @param logArray array where the log was generated
 * @param logAntenna antenna where the log was generated
 */
#define LOG_WITH_ANTENNA_CONTEXT(logPriority, logRoutine, logMessage, logArray, logAntenna) \
if (getLogger()!=0) \
{ \
    Logging::BaseLog::LogRecord lr; \
    lr.priority  = Logging::ace2acsPriority(logPriority); \
    lr.message   = logMessage; \
    lr.file      = __FILE__; \
    lr.line      = __LINE__; \
    lr.method    = logRoutine; \
    lr.timeStamp = getTimeStamp(); \
    LoggingProxy::array(logArray); \
    LoggingProxy::antenna(logAntenna); \
    LoggingProxy::Flags(LM_SOURCE_INFO | LM_RUNTIME_CONTEXT); \
    getLogger()->log(lr); \
} \
else \
{ \
  std::cerr << "SEVERE LOGGING ERROR - getLogger() returned NULL: file="; \
  std::cerr << __FILE__ << ", line=" << __LINE__ << std::endl; \
}

/**
 * Used to send logs. This macro is primarily useful because it automatically
 * determines the file name and line number for the developer.
 * @param logPriority Logging::BaseLog::Priority of the log message
 * @param logRoutine Name of the routine in which this macro is being used from (std::string)
 * @param logMessage Log message (std::string)
 * @param logAudience intended receiver of this log message
 */
#define LOG_TO_AUDIENCE(logPriority, logRoutine, logMessage, logAudience) \
if (getLogger()!=0) \
{ \
    Logging::BaseLog::LogRecord lr; \
    lr.priority  = Logging::ace2acsPriority(logPriority); \
    lr.message   = logMessage; \
    lr.file      = __FILE__; \
    lr.line      = __LINE__; \
    lr.method    = logRoutine; \
    lr.timeStamp = getTimeStamp(); \
    LoggingProxy::audience(logAudience); \
    LoggingProxy::Flags(LM_SOURCE_INFO | LM_RUNTIME_CONTEXT); \
    getLogger()->log(lr); \
} \
else \
{ \
  std::cerr << "SEVERE LOGGING ERROR - getLogger() returned NULL: file="; \
  std::cerr << __FILE__ << ", line=" << __LINE__ << std::endl; \
}

/**
 * Used to publish a log record. Useful for doing things like setting
 * a specific time the log was sent (rather than letting ACS figure this
 * out for you).
 * @param logPriority  ACS priority of the log.
 * @param logMessage  Log message (string).
 * @param logFile  Name of the file the log was published from (__FILE__)
 * @param logLine  Line number from where the log was published (__LINE__)
 * @param logRoutine  Name of the routine from where the log was published (string)
 * @param logTime  Time the log was published (ACS::Time)
 * @param logSource Source of the log (i.e., container name, component name, etc)
 */
#define LOG_RECORD(logPriority, logMessage, logFile, logLine, logRoutine, logTime, logSource) \
if (getLogger()!=0) \
{ \
    Logging::BaseLog::LogRecord lr; \
    lr.priority  = logPriority; \
    lr.message   = logMessage; \
    lr.file      = logFile; \
    lr.line      = logLine; \<commit_msg>Fixed bug caused by a out bounds memory access in audience string pointer<commit_after>#ifndef logging_macros_H
#define logging_macros_H
/*******************************************************************************
* ALMA - Atacama Large Millimiter Array
* (c) UNSPECIFIED - FILL IN, 2005
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*
* "@(#) $Id: loggingMACROS.h,v 1.23 2009/11/19 20:51:47 javarias Exp $"
*
* who       when      what
* --------  --------  ----------------------------------------------
* dfugate  2005-04-04  created
*/

#ifndef __cplusplus
#error This is a C++ include file and cannot be used from plain C
#endif

#include "loggingLogger.h"
#include "loggingLogTrace.h"
#include "loggingGetLogger.h"
#include <iostream>
#include <acsutilTimeStamp.h>

/**
 * Used to send logs. This macro is primarily useful because it automatically
 * determines the file name and line number for the developer. It is important
 * to note that getLogger() is defined in a header file other than what's included
 * above. UPDATE: I just included the file, don't know why it wasn't included before.
 * @param priority Logging::BaseLog::Priority of the log message
 * @param routine Name of the routine in which this macro is being used from (std::string)
 * @param text Log message (std::string)
 */
#define LOG(priority, routine, text) \
if (getLogger()!=0) \
{ \
  getLogger()->log(priority, text, __FILE__, __LINE__, routine); \
} \
else \
{ \
  std::cerr << "SEVERE LOGGING ERROR - getLogger() returned NULL: file="; \
  std::cerr << __FILE__ << ", line=" << __LINE__ << std::endl; \
}


/**
 * Used to send logs. This macro is primarily useful because it automatically
 * determines the file name and line number for the developer.
 * @param logPriority Logging::BaseLog::Priority of the log message
 * @param logRoutine Name of the routine in which this macro is being used from (std::string)
 * @param logMessage Log message (std::string)
 * @param logAudience intended receiver of this log message
 * @param logArray array where the log was generated
 * @param logAntenna antenna where the log was generated
 */
#define LOG_FULL(logPriority, logRoutine, logMessage, logAudience, logArray, logAntenna) \
if (getLogger()!=0) \
{ \
    Logging::BaseLog::LogRecord lr; \
    lr.priority  = Logging::ace2acsPriority(logPriority); \
    lr.message   = logMessage; \
    lr.file      = __FILE__; \
    lr.line      = __LINE__; \
    lr.method    = logRoutine; \
    lr.timeStamp = getTimeStamp(); \
    LoggingProxy::audience(logAudience); \
    LoggingProxy::array(logArray); \
    LoggingProxy::antenna(logAntenna); \
    LoggingProxy::Flags(LM_SOURCE_INFO | LM_RUNTIME_CONTEXT); \
    getLogger()->log(lr); \
	 LoggingProxy::audience(NULL); \
} \
else \
{ \
  std::cerr << "SEVERE LOGGING ERROR - getLogger() returned NULL: file="; \
  std::cerr << __FILE__ << ", line=" << __LINE__ << std::endl; \
}

/**
 * Used to send logs. This macro is primarily useful because it automatically
 * determines the file name and line number for the developer.
 * @param logPriority Logging::BaseLog::Priority of the log message
 * @param logRoutine Name of the routine in which this macro is being used from (std::string)
 * @param logMessage Log message (std::string)
 * @param logArray array where the log was generated
 * @param logAntenna antenna where the log was generated
 */
#define LOG_WITH_ANTENNA_CONTEXT(logPriority, logRoutine, logMessage, logArray, logAntenna) \
if (getLogger()!=0) \
{ \
    Logging::BaseLog::LogRecord lr; \
    lr.priority  = Logging::ace2acsPriority(logPriority); \
    lr.message   = logMessage; \
    lr.file      = __FILE__; \
    lr.line      = __LINE__; \
    lr.method    = logRoutine; \
    lr.timeStamp = getTimeStamp(); \
    LoggingProxy::array(logArray); \
    LoggingProxy::antenna(logAntenna); \
    LoggingProxy::Flags(LM_SOURCE_INFO | LM_RUNTIME_CONTEXT); \
    getLogger()->log(lr); \
} \
else \
{ \
  std::cerr << "SEVERE LOGGING ERROR - getLogger() returned NULL: file="; \
  std::cerr << __FILE__ << ", line=" << __LINE__ << std::endl; \
}

/**
 * Used to send logs. This macro is primarily useful because it automatically
 * determines the file name and line number for the developer.
 * @param logPriority Logging::BaseLog::Priority of the log message
 * @param logRoutine Name of the routine in which this macro is being used from (std::string)
 * @param logMessage Log message (std::string)
 * @param logAudience intended receiver of this log message
 */
#define LOG_TO_AUDIENCE(logPriority, logRoutine, logMessage, logAudience) \
if (getLogger()!=0) \
{ \
    Logging::BaseLog::LogRecord lr; \
    lr.priority  = Logging::ace2acsPriority(logPriority); \
    lr.message   = logMessage; \
    lr.file      = __FILE__; \
    lr.line      = __LINE__; \
    lr.method    = logRoutine; \
    lr.timeStamp = getTimeStamp(); \
    LoggingProxy::audience(logAudience); \
    LoggingProxy::Flags(LM_SOURCE_INFO | LM_RUNTIME_CONTEXT); \
    getLogger()->log(lr); \
	 LoggingProxy::audience(NULL); \
} \
else \
{ \
  std::cerr << "SEVERE LOGGING ERROR - getLogger() returned NULL: file="; \
  std::cerr << __FILE__ << ", line=" << __LINE__ << std::endl; \
}

/**
 * Used to publish a log record. Useful for doing things like setting
 * a specific time the log was sent (rather than letting ACS figure this
 * out for you).
 * @param logPriority  ACS priority of the log.
 * @param logMessage  Log message (string).
 * @param logFile  Name of the file the log was published from (__FILE__)
 * @param logLine  Line number from where the log was published (__LINE__)
 * @param logRoutine  Name of the routine from where the log was published (string)
 * @param logTime  Time the log was published (ACS::Time)
 * @param logSource Source of the log (i.e., container name, component name, etc)
 */
#define LOG_RECORD(logPriority, logMessage, logFile, logLine, logRoutine, logTime, logSource) \
if (getLogger()!=0) \
{ \
    Logging::BaseLog::LogRecord lr; \
    lr.priority  = logPriority; \
    lr.message   = logMessage; \
    lr.file      = logFile; \
    lr.line      = logLine; \
{'fraction_non_alphanumeric': 0.13049287410926366, 'fraction_numerical': 0.007868171021377672, 'mean_word_length': 3.612461485792537, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5624427', 'n_tokens_mistral': 4158, 'n_tokens_neox': 4008, 'n_words': 1434}