2015-09-18 13:40:51 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Print logging messages through the ACE framework.
|
2015-01-16 23:21:47 +00:00
|
|
|
*
|
2015-09-18 13:40:51 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: Message <ANY>
|
|
|
|
* 1: Level (default: 2) <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Message is Printed <BOOL>
|
|
|
|
*
|
|
|
|
* Public: Yes
|
2015-01-16 23:21:47 +00:00
|
|
|
*/
|
|
|
|
#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-09-18 13:40:51 +00:00
|
|
|
params ["_msg", ["_level", 2, [0]]];
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-09-18 13:40:51 +00:00
|
|
|
private ["_defaultLoglevel", "_defaultLogDisplayLevel"];
|
2015-01-21 14:52:11 +00:00
|
|
|
|
2015-09-18 13:40:51 +00:00
|
|
|
_defaultLoglevel = [GVAR(LOGLEVEL), DEFAULT_LOGGING_LEVEL] select isNil QGVAR(LOGLEVEL);
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-09-18 13:40:51 +00:00
|
|
|
if (_defaultLoglevel < 0) exitwith {false};
|
2015-01-21 14:52:11 +00:00
|
|
|
|
2015-09-18 13:40:51 +00:00
|
|
|
_defaultLogDisplayLevel = [GVAR(LOGDISPLAY_LEVEL), DEFAULT_TEXT_DISPLAY] select isNil QGVAR(LOGDISPLAY_LEVEL);
|
2015-01-16 23:21:47 +00:00
|
|
|
|
|
|
|
if (_level <= _defaultLoglevel) then {
|
2015-09-18 13:40:51 +00:00
|
|
|
private ["_prefix", "_message"];
|
|
|
|
|
2015-09-18 19:46:21 +00:00
|
|
|
_prefix = ["Error", "Warn", "Debug", "Info"] select (_level min 3);
|
2015-09-18 13:40:51 +00:00
|
|
|
|
|
|
|
_message = format ["[ACE %1] %2", _prefix, _msg];
|
2015-01-18 19:09:19 +00:00
|
|
|
|
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
|
|
|
};
|
2015-09-18 13:40:51 +00:00
|
|
|
|
2015-08-26 13:20:11 +00:00
|
|
|
true
|