Is there any way to fetch whether or not the advantagekit logger is running or not?

Currently, some of our code depends on whether or not the advantagekit logger is running or not. Is there any way to check for this?

Thanks,
Daniel

While there is a running field inside the advkit Logger class, its not exposed and is private. Since I assume you invoke Logger.start() in your own code, I believe it should be fairly trivial to track the state of the logger yourself…

However, can you speak more about why you depend on knowing the state of the logger in your code? At least for us, because we call Logger.start() in robotInit(), we can safely assume its active/running for all code that happens after robotInit(). Depending on your use case, im not sure if depending on the state of the logger is the best way to accomplish what you need.

yeah, I was thinking of that too; however, I realized this:

image

When end() is called, Logger.running becomes false; however, I can’t exactly track when that happens without calling updateTable another time, which might mess up replay.

If the logger is not currently running, i’m afraid that accidentally pushing data to a log table might throw an exception or mess something up.

If the logger is not running, any calls to processInputs or recordOutput will exit without changing anything. The snippet you showed it called at the end of log replay (when the replay source has no more data), and causes the robot code to exit. What are you trying to accomplish that requires starting and stopping the logger outside of robotInit?

I’m not trying to start or stop the logger; I just need to double check that it is running.

Since that end() function is called during replay and the robot code is exited immediately afterwards, I think my problem here is mostly solved(I just keep track of the logger’s state in the robot class too).

I was trying to write a generic AdvantageKitLoggable interface that allows custom stuff to be pushed and pulled from log(with a LogTable and category string passed into the functions).

I wanted to add a recordAsOutput() function that places the outputs of the class into the RealOutputs/ReplayOutputs category(essentially mimmicking Logger.recordOutput(), but for custom classes). However, I was afraid that by calling table.put() when the running static variable of logger was false, something might go wrong; thus, I wanted to make sure that the logger was running before doing that.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.