BIS fnc logFormat: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Created page with "<syntaxhighlight lang=javascript>/* Author: Karel Moricky Description: Display debug message Parameter(s): _this select 0: STRING - Formatted message or first param _this...")
m (sa)
 
(33 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<syntaxhighlight lang=javascript>/*
{{RV|type=function
Author: Karel Moricky


Description:
|game1= arma3
Display debug message
|version1= 1.00


Parameter(s):
|gr1= Diagnostic
_this select 0: STRING - Formatted message or first param
_this select n (Optional): ANY - additional parameters


Returns:
|descr= Display debug message.
BOOL - true when done
{{Feature|informative|{{hl|[[Description.ext#allowFunctionsLog|allowFunctionsLog]]}} has to be set to '''1''' in [[Description.ext]] for this function to have any effect.}}
*/


private["_omit"];
|s1= [text, parameters] call [[BIS_fnc_logFormat]]


if (isNil "_fnc_log_disable") then
|p1= '''text''': [[String]] - formatted message or first param
{
_omit = false;
}
else
{
_omit = _fnc_log_disable;
};


if (_omit) exitWith {false};
|p2= '''parameters''': [[Anything]] - (Optional) additional parameters


private ["_scriptName","_text"];
|r1= [[Boolean]] - [[true]] when done


//--- Insert function name where available
|x1= <sqf>["My logged name: %1, My position: %2", name player, getPos player] call BIS_fnc_logFormat;
_scriptName = if (isnil "_fnc_scriptName"/* || isnil "_fnc_scriptNameParent"*/) then {
// RPT output:
""
// 12:34:56 "BIS_fnc_log: [BIS_fnc_debugConsoleExec] My logged name: Miller, My position: [4866.73,21947.9,0.00143433]"</sqf>
} else {
_fnc_scriptName
};
_scriptName = if (_scriptName != "") then {" [" + _scriptName + "] "} else {" "};


 
|seealso= [[BIS_fnc_error]] [[BIS_fnc_logFormatServer]] [[BIS_fnc_errorMsg]] [[BIS_fnc_log]]
//--- Display
}}
if (typename _this != typename []) then {_this = [_this]};
if (count _this == 0) then {_this = ["<EMPTY ARRAY>"]};
_text = _this select 0;
if (typename _text != typename "") then {_text = str _this;};
_thisLocal = +_this;
_thisLocal set [0,profilename + "/BIS_fnc_log:" + _scriptName + _text];
 
if (getnumber (missionconfigfile >> "allowFunctionsLog") > 0 || cheatsEnabled) then {
diag_log format _thisLocal
};
 
true
</syntaxhighlight>

Latest revision as of 22:46, 30 December 2023

Hover & click on the images for description

Description

Description:
Display debug message.
allowFunctionsLog has to be set to 1 in Description.ext for this function to have any effect.
Execution:
call
Groups:
Diagnostic

Syntax

Syntax:
[text, parameters] call BIS_fnc_logFormat
Parameters:
text: String - formatted message or first param
parameters: Anything - (Optional) additional parameters
Return Value:
Boolean - true when done

Examples

Example 1:
["My logged name: %1, My position: %2", name player, getPos player] call BIS_fnc_logFormat; // RPT output: // 12:34:56 "BIS_fnc_log: [BIS_fnc_debugConsoleExec] My logged name: Miller, My position: [4866.73,21947.9,0.00143433]"

Additional Information

See also:
BIS_fnc_error BIS_fnc_logFormatServer BIS_fnc_errorMsg BIS_fnc_log

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note