Skip to content

Commit

Permalink
use log macros in settings component
Browse files Browse the repository at this point in the history
  • Loading branch information
commy2 committed Aug 16, 2016
1 parent b0c301b commit bd80d2d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions addons/settings/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// --- refresh all settings after postInit to guarantee that events are added and settings are recieved from server
{
if (isNil QGVAR(serverSettings)) then {
diag_log text "[CBA] (settings): No server settings after postInit phase.";
ERROR("No server settings after postInit phase.");
};

//Event to read modules
Expand All @@ -14,7 +14,7 @@
[QGVAR(refreshSetting), _x] call CBA_fnc_localEvent;
} forEach GVAR(allSettings);

diag_log text format ["[CBA] (settings): Settings Initialized"];
LOG("Settings Initialized");
["CBA_settingsInitialized", []] call CBA_fnc_localEvent;
} call CBA_fnc_execNextFrame;

Expand Down
10 changes: 6 additions & 4 deletions addons/settings/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ addMissionEventHandler ["Loaded", {
["CBA_SettingChanged", {
params ["_setting", "_value"];

private _message = format ["[CBA] (settings): %1 = %2", _setting, _value];
private _message = format ["%1 = %2", _setting, _value];
systemChat _message;
diag_log text _message;
LOG(_message);
}] call CBA_fnc_addEventHandler;
#endif

Expand All @@ -68,10 +68,12 @@ if (isServer) then {
params ["_setting", "_value", ["_forced", false, [false]]];

if ([_setting, "mission"] call FUNC(isForced)) exitWith {
diag_log text format ["[CBA] (settings): Setting %1 already forced, ignoring setSettingMission.", _setting];
private _message = format ["Setting %1 already forced, ignoring setSettingMission.", str _setting];
LOG(_message);
};
if (!([_setting, _value] call FUNC(check))) exitWith {
diag_log text format ["[CBA] (settings): Value %1 is invalid for setting %2.", _value, _setting];
private _message = format ["Value %1 is invalid for setting %2.", _value, str _setting];
WARNING(_message);
};

GVAR(missionSettings) setVariable [_setting, [_value, _forced]];
Expand Down
3 changes: 2 additions & 1 deletion addons/settings/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ if (!isNil "_settingInfo") then {
if !([_setting, _value] call FUNC(check)) then {
_value = [_setting, "default"] call FUNC(get);
[_setting, _value, _forced, "client"] call FUNC(set);
diag_log text format ["[CBA] (settings): Invalid value for setting %1. Fall back to default value.", str _setting];
private _message = format ["Invalid value for setting %1. Fall back to default value.", str _setting];
WARNING(_message);
};

GVAR(clientSettings) setVariable [_setting, [_value, _forced]];
Expand Down
6 changes: 4 additions & 2 deletions addons/settings/fnc_parse.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ private _result = [];
private _currentValue = [_setting, "default"] call FUNC(get);

if (isNil "_currentValue") then {
diag_log text format ["[CBA] (settings): Error parsing settings file. Setting %1 does not exist.", str _setting];
private _message = format ["Error parsing settings file. Setting %1 does not exist.", str _setting];
ERROR(_message);
} else {
if ([_setting, _value] call FUNC(check)) then {
_result pushBack [_setting, _value, _force];
} else {
diag_log text format ["[CBA] (settings): Error parsing settings file. Value %1 is invalid for setting %2.", _value, str _setting];
private _message = format ["Error parsing settings file. Value %1 is invalid for setting %2.", _value, str _setting];
ERROR(_message);
};
};
};
Expand Down
3 changes: 2 additions & 1 deletion addons/settings/fnc_set.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Author:
params [["_setting", "", [""]], "_value", ["_forced", nil, [false]], ["_source", "client", [""]]];

if (!isNil "_value" && {!([_setting, _value] call FUNC(check))}) exitWith {
diag_log text format ["[CBA] (settings): Value %1 is invalid for setting %2.", _value, str _setting];
private _message = format ["Value %1 is invalid for setting %2.", _value, str _setting];
WARNING(_message);
1
};

Expand Down
6 changes: 3 additions & 3 deletions optionals/auto_load_settings_file/loadSettingsFile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ if (isFilePatchingEnabled) then {

if (_file != "") then {
[_file, _source] call EFUNC(settings,import);
diag_log text "[CBA] (settings): Settings file loaded.";
LOG("Settings file loaded.");
} else {
diag_log text "[CBA] (settings): Settings file not loaded. File empty or does not exist.";
WARNING("Settings file not loaded. File empty or does not exist.");
};
} else {
diag_log text "[CBA] (settings): Cannot load settings file. File patching disabled. Use -filePatching flag.";
WARNING("Cannot load settings file. File patching disabled. Use -filePatching flag.");
};
2 changes: 1 addition & 1 deletion template/static_settings_addon/loadSettingsFile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ private _source = ["client", "server"] select (isMultiplayer && isServer);
private _file = loadFile PATH_SETTINGS_FILE_PBO;

[_file, _source] call EFUNC(settings,import);
diag_log text "[CBA] (settings): Settings file loaded from PBO.";
LOG("Settings file loaded from PBO.");

0 comments on commit bd80d2d

Please sign in to comment.