big refactor, WIP!
This commit is contained in:
33
framework/common/functions/fn_log.sqf
Normal file
33
framework/common/functions/fn_log.sqf
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Function: milsim_util_fnc_log
|
||||
|
||||
Description:
|
||||
Used to log messages to the server RPT file.
|
||||
|
||||
Parameters:
|
||||
0: NUMBER - log level.
|
||||
1: STRING - component name.
|
||||
2: STRING - message to log.
|
||||
3: ARRAY - key value pairs of data to log.
|
||||
*/
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
params [
|
||||
["_logLevel", 1, [-1,0,1,2,3]], // script_mod.hpp
|
||||
["_component", "", [""]],
|
||||
["_message", "", [""]],
|
||||
["_data", [], [[]]]
|
||||
];
|
||||
|
||||
if (_logLevel < LOG_LEVEL) exitWith {};
|
||||
|
||||
private _hash = createHashMapFromArray _data;
|
||||
|
||||
// Replace square brackets with round brackets to avoid parsing issues.
|
||||
_message regexReplace ["\[", "("];
|
||||
_message regexReplace ["\]", ")"];
|
||||
|
||||
private _json = [_hash] call CBA_fnc_encodeJSON;
|
||||
_log = format ["[%1] [%2] [%3] [%4] :: %5", QUOTE(PREFIX), _component, _fnc_scriptNameParent, _message, _json];
|
||||
|
||||
diag_log text _log;
|
||||
Reference in New Issue
Block a user