Saving trace output to file

Post here your suggestions for new possible features in SmartFoxServer.

Moderators: Lapo, Bax

Post Reply
NateDog
Posts: 52
Joined: 26 Jun 2006, 13:25

Saving trace output to file

Post by NateDog »

on a zone by zone basis, the ability to write all trace output to a specific file would be very handy. certainly not a high priority, but a nice to have item for the wish list.
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Post by Virusescu »

You have the ability to write to files using _server.writeFile();
writing a trace function would be really simple

Code: Select all

function traceToFile(text) {
var date = new Date();
// format your date here like for example
yourDate = "30/06/2006  14:30:21";
text = yourDate + " - " +text;
_server.writeFile(_server.getCurrentZone().getName()+".log", text, true);
}
// then you call it like
traceToFile ("some text");
It will write to a .log file with the name of the current zone, the message passed as a parameter along with the date and time when the trace was called.
function onJoin(usr) {if (usr.getName() == "Lapo") trace ("All Hail Lapo");}
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

There's also the logger object that can be used to trace debug data to the SFS standard logger, which also saves in the log files.

Check our ServerSide documentation
Lapo
--
gotoAndPlay()
...addicted to flash games
NateDog
Posts: 52
Joined: 26 Jun 2006, 13:25

Post by NateDog »

yeah - i guess i can go through and do a massive search/replace of "trace(" to "traceToFile(" ... i was just looking for a lazy solution :wink:

*goes to read about logging object*
Post Reply