Undefined messageClass in log(this.x,this.y) causes CTD.

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Undefined messageClass in log(this.x,this.y) causes CTD.

Post by Switeck »

Supporting what you said...

This works:
log(testCounter," = testCounter");
log("testCounter = ",testCounter);
log(this.name,"testCounter = "+testCounter);

This doesn't work:
log("testCounter = "+testCounter);
log(this.name+"testCounter = "+testCounter);

The ones that work have a comma in the log list.
The ones that don't I guess go only to the debugger window, if it's running. On windows Oolite, it usually isn't. :P
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Undefined messageClass in log(this.x,this.y) causes CTD.

Post by JensAyton »

Switeck wrote:
This doesn't work:
log("testCounter = "+testCounter);
log(this.name+"testCounter = "+testCounter);
As Eric said, it does work, but it’s hidden by default. If you want it to be visible by default, you must specify a log message class so it can be deactivated individually.

(This is because log was originally a port of the legacy script method debugMessage:, which was only active after calling debugOn. This allowed you to disable logging in a script by commenting out debugOn and debugOff. The JS equivalent to debugOn is console.setDisplayMessagesInClass("$scriptDebugOn", true), which only works if the debug console is active.)
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Undefined messageClass in log(this.x,this.y) causes CTD.

Post by Capt. Murphy »

Commander McLane wrote:
Eric Walch wrote:
Commander McLane wrote:
I don't think that the entity ID would be particularly useful. It's just a three-digit-number that Oolite assigns to each entity in order of its creation. So there is no connection between the ID and any useful information about the ship itself. this.ship.name would be vastly more useful in my opinion.
entity.ID was deprecated since 1.74 and is no longer available to scripts for the reason you mention. At any time they are unique, but when a ship dies, the same number may be re-issued to a new ship.
I think Capt. Murphy means entityPersonality. That is a bigger, random number. Ship.name is not useful as they probably will also be the same when you add 10 of the same ships in the universe and they all add logging lines.
My thinking was: A ship creator builds a logging feature into his newest creation an ships the OXP with this logging feature. I install the OXP, find some loggings in my log and want to contact the OXP creator about them. The entityPersonality is of no use at all, because it's unique to my current game. If the OXP creator fires up his game and spawns one of his ships, it will have a totally different entityPersonality. Besides, the entityPersonality, which is just a long number, tells me nothing about which ship created the log entry in the first place, which OXP it is from, and who I should contact about it. But if the name is logged I can easily find out that the "Rhinoceros" was created by "Commander Big Five" and can PM him about it.
McClane, I think you've misunderstood my intention - I'm thinking of more useful log functions for the script-writer during development and testing/debugging - not necessarily for inclusion in release scripts. Take Thargoid's Swarm.oxp as an example which is a shipscript potentially attached to many entities at any one time all with the same this.ship.name. When debugging the earlier versions with the anomolous NaN's it would have been useful to be able to include a log entry under each function which included a unique ID for the entity for which that function was running at the time. The resulting log file would then show in what order functions were called for each specific entity, which I think would have made it much easier to confirm the cause of the problem.

Eric - entityPersonality is exactly what I was looking for - thanks for the heads up.

edit 2 add - got some very useful debug info out of the earlier Swarm.oxp using log commands such as this as the first line of the named functions.....

log(this.name,"this.shipSpawned fired for Entity "+this.ship.entityPersonality)
log(this.name,"this.startWeave fired for Entity "+this.ship.entityPersonality)
log(this.name,"this.performWeave fired for Entity "+this.ship.entityPersonality); log(this.name,"Entity "+this.ship.entityPersonality+", this.weaveX: "+this.weaveX+" this.weaveY: "+this.weaveY)

Gave useful output like this using Notepad++ to extract the lines for Entity 19804
Line 46: 05:29:32.487 [swarm_thargoid]: this.startWeave fired for Entity 19804
Line 71: 05:29:32.562 [swarm_thargoid]: this.performWeave fired for Entity 19804
Line 72: 05:29:32.562 [swarm_thargoid]: Entity 19804, this.weaveX: undefined this.weaveY: undefined
Line 122: 05:29:32.585 [swarm_thargoid]: this.shipSpawned fired for Entity 19804
Line 123: 05:29:32.585 [swarm_thargoid]: this.startWeave fired for Entity 19804
Line 160: 05:29:32.597 [swarm_thargoid]: this.performWeave fired for Entity 19804
Line 161: 05:29:32.597 [swarm_thargoid]: Entity 19804, this.weaveX: 2 this.weaveY: 2
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Undefined messageClass in log(this.x,this.y) causes CTD.

Post by Eric Walch »

Capt. Murphy wrote:
Gave useful output like this using Notepad++ to extract the lines for Entity 19804
Same is easy done with the 'Console' on the mac. Just type a string in the 'filter' field in the upper right corner, and the console only shows the log lines containing that string.
Post Reply