cooja icon indicating copy to clipboard operation
cooja copied to clipboard

How can I get the Cooja sources code's log output?

Open LeoLee0097 opened this issue 3 years ago • 1 comments

Dear all, I add 3 lines in the file [contiki-ng]/tools/cooja/apps/powertracker/java/PowerTracker.java to see the timing they call the radio.isTransmitting(), radio.isReceiving() and radio.isInterfered().

public MoteTracker(Mote mote) {
      this.simulation = mote.getSimulation();
      this.mote = mote;
      this.radio = mote.getInterfaces().getRadio();
      radioWasOn = radio.isRadioOn();
      if (radio.isTransmitting()) {
        lastRadioState = RadioState.TRANSMITTING;
        log("PowerTracker - Tx\n");//Add
      } else if (radio.isReceiving()) {
        lastRadioState = RadioState.RECEIVING;
        log("PowerTracker - Rx\n");//Add
      } else if (radio.isInterfered()) {
        lastRadioState = RadioState.INTERFERED;
        log("PowerTracker - INT\n");//Add
      } else {
        lastRadioState = RadioState.IDLE;
      }
      lastUpdateTime = simulation.getSimulationTime();
      radio.addObserver(this);
    }

How could I set the log level for Cooja source files, and where could I see the log outputs?

LeoLee0097 avatar Feb 18 '22 10:02 LeoLee0097

If you use logger.info instead of log, the output will go to the console.

If you want that information to also be written to a file, you can pass -logfile=name.log to Cooja (so for latest master in the docker image, cooja --args="-logfile=name.log -logdir=/tmp" will write /tmp/name.log).

pjonsson avatar Nov 08 '22 10:11 pjonsson