Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LeoLee0097 opened this issue Feb 18, 2022 · 1 comment
Open

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

LeoLee0097 opened this issue Feb 18, 2022 · 1 comment

Comments

@LeoLee0097
Copy link

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?

pjonsson added a commit to pjonsson/cooja that referenced this issue May 25, 2022
Commits:
c8169c9 Merge pull request contiki-ng#65 from pjonsson/add-multistep
f44a442 Allow stepping multiple instructions
1c3d09c Merge pull request contiki-ng#64 from pjonsson/gcc9-support
cecca91 Merge pull request contiki-ng#63 from pjonsson/fix-test-warnings
eae0cab Merge pull request contiki-ng#61 from pjonsson/fix-test-makefile
3b81ed1 tests: add GCC 9 support
9182260 tests: add -gstabs+ to CFLAGSNO
ec1498b tests: only pass -mmcu once
78e45ee tests: remove unused functions
@pjonsson
Copy link
Contributor

pjonsson commented Nov 8, 2022

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants