2015-01-16 23:21:47 +00:00
|
|
|
/**
|
|
|
|
* fn_debug.sqf
|
|
|
|
* @Descr: Print logging messages through the ACE framework.
|
|
|
|
* @Author: Glowbal
|
|
|
|
*
|
|
|
|
* @Arguments: [message ANY, level NUMBER (Optional)]
|
|
|
|
* @Return: BOOL True if message has been printed
|
|
|
|
* @PublicAPI: true
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-01-22 22:49:04 +00:00
|
|
|
#define DEFAULT_LOGGING_LEVEL -1
|
|
|
|
#define DEFAULT_TEXT_DISPLAY -1
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-05-14 22:17:41 +00:00
|
|
|
private ["_level", "_prefix", "_defaultLoglevel","_defaultLogDisplayLevel", "_message"];
|
2015-05-14 18:06:06 +00:00
|
|
|
PARAMS_1(_msg);
|
2015-01-16 23:21:47 +00:00
|
|
|
_level = if (count _this > 1) then {_this select 1} else { 2 };
|
|
|
|
|
2015-01-21 14:52:11 +00:00
|
|
|
if (typeName _level != "NUMBER") then {
|
|
|
|
_level = 2;
|
|
|
|
};
|
|
|
|
|
2015-01-16 23:21:47 +00:00
|
|
|
_defaultLoglevel = if (isNil QGVAR(LOGLEVEL)) then {
|
2015-01-18 19:09:19 +00:00
|
|
|
DEFAULT_LOGGING_LEVEL;
|
2015-01-16 23:21:47 +00:00
|
|
|
} else {
|
2015-01-18 19:09:19 +00:00
|
|
|
GVAR(LOGLEVEL);
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
|
|
|
|
2015-01-21 14:52:11 +00:00
|
|
|
if (_defaultLoglevel < 0) exitwith {
|
|
|
|
false
|
|
|
|
};
|
|
|
|
|
2015-01-16 23:21:47 +00:00
|
|
|
_defaultLogDisplayLevel = if (isnil QGVAR(LOGDISPLAY_LEVEL)) then {
|
2015-01-18 19:09:19 +00:00
|
|
|
DEFAULT_TEXT_DISPLAY;
|
2015-01-16 23:21:47 +00:00
|
|
|
} else {
|
2015-01-18 19:09:19 +00:00
|
|
|
GVAR(LOGDISPLAY_LEVEL);
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (_level <= _defaultLoglevel) then {
|
|
|
|
|
2015-01-18 19:09:19 +00:00
|
|
|
_prefix = switch (_level) do {
|
|
|
|
case 0: { "ACE Error" };
|
|
|
|
case 1: { "ACE Warn" };
|
|
|
|
case 2: { "ACE Debug" };
|
|
|
|
case 3: { "ACE Info" };
|
|
|
|
default { "ACE Unknown" };
|
|
|
|
};
|
|
|
|
_message = format["[%1] %2",_prefix,_msg];
|
|
|
|
|
2015-01-21 14:52:11 +00:00
|
|
|
if (_level <= _defaultLogDisplayLevel) then {
|
2015-01-18 19:09:19 +00:00
|
|
|
systemChat _message;
|
|
|
|
};
|
|
|
|
diag_log _message;
|
|
|
|
|
|
|
|
// pass it onwards to the log function:
|
|
|
|
// [0, [], compile format["%1",_msg], true] call FUNC(log);
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
|
|
|
true
|