I have seen a couple of threads where debugging is becoming an issue and thought I would share one of the tools I have written.
Basically it allows you to add an entry to the server log, normally done with diag_log at the server, from the client (player) side of your mission scripts. Normally, for the client, hint is the only way to do any sensible debugging. I now use this religiously when scripting.
All this does is setup a public variable event handler that, when called, runs a small script on the server that logs whatever is sent to it via the public variable.
The reason for this requirement, if you have tried doing a diag_log from the client you will have noticed that nothing appears in the server log. This is because of locality. In short, not all things are available to the client that are for the server and vice/versa.
If you are serious about scripting locality is one thing you will want to get your head around, it explains why a lot of things that, at first glance, appear like they should work but just don't..
To Install:
In init.sqf (in your mission folder) add (Or add the relevant code to an existing isServer):
if (isServer) then {
axe_server_log = compile preprocessFileLineNumbers "tools\logtorpt.sqf";
"axeDiagLog" addPublicVariableEventHandler {_id = (_this select 1) spawn axe_server_log};
};
Create a folder called tools in your mission folder and add logtorpt.sqf (this can be packaged in, and referenced from, dayz_server.pbo):
Then when you want to create a log entry from your clientside code use this as an example (the key bits are the last two lines):
_var1 = "wow";
_var2 = "a log entry.";
axeDiagLog = format["I am logging something here: 1st Var=%1 | 2nd Var=%2.",_var1,_var2];//Set the public variable value
publicVariable "axeDiagLog";//Send the public variable 'to the event handler'
Obviously you can make axeDiagLog pretty much anything you want. That example will then appear in your server side log as:
This is creating public variables so may cause network issues if overdone. Always remove for live servers to increase performance.
That said I have had this running at hundreds of logs per second on my test server and had no noticeable lag with 2 to 3 players in testing. Is entirely possible this could be optimised using publicVariableServer instead, it works so I haven't 'fixed' it.
That's it, server side logging from the client, enjoy.. :)
Question
axeman
I have seen a couple of threads where debugging is becoming an issue and thought I would share one of the tools I have written.
Basically it allows you to add an entry to the server log, normally done with diag_log at the server, from the client (player) side of your mission scripts. Normally, for the client, hint is the only way to do any sensible debugging. I now use this religiously when scripting.
All this does is setup a public variable event handler that, when called, runs a small script on the server that logs whatever is sent to it via the public variable.
The reason for this requirement, if you have tried doing a diag_log from the client you will have noticed that nothing appears in the server log. This is because of locality. In short, not all things are available to the client that are for the server and vice/versa.
If you are serious about scripting locality is one thing you will want to get your head around, it explains why a lot of things that, at first glance, appear like they should work but just don't..
To Install:
In init.sqf (in your mission folder) add (Or add the relevant code to an existing isServer):
Create a folder called tools in your mission folder and add logtorpt.sqf (this can be packaged in, and referenced from, dayz_server.pbo):
Then when you want to create a log entry from your clientside code use this as an example (the key bits are the last two lines):
Obviously you can make axeDiagLog pretty much anything you want. That example will then appear in your server side log as:
This is creating public variables so may cause network issues if overdone. Always remove for live servers to increase performance.
That said I have had this running at hundreds of logs per second on my test server and had no noticeable lag with 2 to 3 players in testing. Is entirely possible this could be optimised using publicVariableServer instead, it works so I haven't 'fixed' it.
That's it, server side logging from the client, enjoy.. :)
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now