Skip to content

Log filtering using Memory.debugTrace

Karl the Pagan edited this page Jan 23, 2017 · 1 revision

Trace logging API

global.trace(category, entityWhere, ...message) global.logError(message, entityWhere)

These methods provide a powerful log filtering mechanism which can help you debug and triage what is happening with your Screeps colony.

Tracing a single creep

First, make sure that your viral.parameter.js has the following entries:

DEBUG: true,
TRACE: true,

Next, setting trace on an individual creep is a convenience method to enable tracing of that creepName: Game.creeps[<creep name>].trace = true

This is identical to the command Memory.debugTrace.creepName = <creep name>

The result is that all debug traces which indicate that creep will be displayed.

TODO SCREENSHOT

Adding debug traces

Example: if( DEBUG && TRACE ) trace('Creep', {creepName:this.name, Behaviour: behaviour && behaviour.name, Creep:'run'}, 'behaviour selected');

Arguments:

  • category - 'Creep' identifies the broad category of event. It will be displayed first in the logs.
  • entityWhere - {creepName:this.name, Behaviour: ... identifies all the components and game entities connected to this trace. Setting Memory.debugTrace.<key> = <value> will narrow down the selection to include matching events and exclude others.
  • message - 'behaviour selected' additional information printed before the contents of entityWhere.

TODO MORE DETAIL

Adding error traces

TODO just like adding a trace, but is displayed when the category 'error' is shown (which it is by default).

Suppressing noise using Memory.debugTrace.no

TODO DETAILS