Published on :
Utility CREATION_INTERNE

Sending a Debug Message to the Log

This code is also available in: Français Deutsch Español
The `_issueDebugMessage` macro is designed to facilitate sending debug messages to a logging system (logger). It takes two parameters: `loggername` (the name of the target logger) and `message` (the content of the debug message). Before calling the `log4sas©_logevent` function, the macro performs validations to check that the `loggername` and `message` parameters are not empty. If any of the parameters is missing, a warning is issued in the SAS© log, and the macro terminates. If the parameters are valid, it uses `%sysfunc(log4sas©_logevent(...))` to send the message. A return code check (`_rc`) is performed, and if it is non-zero, an error is reported. This macro is a component of the SASUNIT_LOG4SAS© ingroup, suggesting its use in a unit testing or development context. Compatibility with SAS© Viya 4 depends on the correct configuration and availability of the Log4SAS© API.
Data Analysis

Type : CREATION_INTERNE


The macro does not directly manipulate SAS datasets. It processes character strings (logger name and message) provided as parameters. These strings are then passed to the `log4sas_logevent` function for logging. There is no dependency on external data or standard SAS libraries like SASHELP for its intrinsic operation.

1 Code Block
MACRO
Explanation :
This block contains the definition of the `_issueDebugMessage` macro. It starts with checks for the presence of the `loggername` and `message` parameters. If a parameter is missing, a `%put` warning is issued, and the macro terminates. If the parameters are valid, the `%sysfunc(log4sas_logevent(...))` function is called to write the debug message to the specified logger. The return code of this function is stored in `_rc` and checked to detect any logging errors.
Copied!
1/**
2 \file
3 \ingroup SASUNIT_LOG4SAS
4 
5 \brief Issues an debug message to a logger
6
7 \version \$Revision$
8 \author \$Author$
9 \date \$Date$
10 
11 \copyright Copyright 2010-2023 HMS Analytical Software GmbH, http://www.analytical-software.de
12 This file is part of SASUnit, the Unit testing framework for SAS(R) programs.
13 For copyright information and terms of usage under the GNU Lesser General Public License see included file README.md
14 or https://github.com/HMS-Analytical-Software/SASUnit/wiki/readme/.
15
16 \param loggername Name of the logger to capture the message
17 \param message Message to be captured by the logger
18 
19 eturn message Message in the associated appender
20*//** \cond */
21%macro _issueDebugMessage(loggername, message);
22 %IF (%LENGTH(&loggername.)=0) %THEN %DO;
23 %put WARNING: loggername is null;
24 %return;
25 %END;
26 %IF (%LENGTH(&message.)=0) %THEN %DO;
27 %put WARNING: message is null;
28 %return;
29 %END;
30 %let _rc = %sysfunc(log4sas_logevent(&loggername., Debug, DEBUG: &message.));
31 %IF (&_rc ne 0) %THEN %DO;
32 %put ERROR: _rc is NOT null: &_rc.;
33 %END;
34%mend _issueDebugMessage;
35/** \endcond */
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright 2010-2023 HMS Analytical Software GmbH, http://www.analytical-software.de This file is part of SASUnit, the Unit testing framework for SAS(R) programs. For copyright information and terms of usage under the GNU Lesser General Public License see included file README.md or https://github.com/HMS-Analytical-Software/SASUnit/wiki/readme/.