Tag Archive: logging

View on GitHub

The PowerEventLog application uses an immutable array to keep track of when the JNIOR turns on and off. It takes the values in an immutable array and stores them in a log file called powereventlog.

The application starts by checking if another instance of  itself is already running. If there is one already running, the instance of it trying to launch terminates itself. After checking that, it then gets the time that the application started on the JNIOR. The Immutable block is then returned (or created if it doesn’t exist yet.) to hold/retrieve the values of when the JNIOR last turned off and when it booted up again. The stop and start times of the JNIOR are re-formatted as date strings to be more readable. The log files being created are then checked to see if a backup needs to be created. Lastly, the stop and start times of the JNIOR are written to the log file, and then the times are updated for the next time the JNIOR turns off.

View on GitHub

JBakup is an application that is running on the JNIOR to help extend the life of your log files.  It does this by monitoring the filesystem for the creating of a .log.bak file.  This logic runs just once every 15 minutes.  When a .log.bak file is found that has NOT been previously processed then it is added to the .zip of the same name in the flash/baks directory.

The JAVA application doesnt take care of the zipping of the backup file data but rather creates a script that the OS executes using the ARC command.

The code is small and should be easy to follow.

Applications can log information they are generating into a .log file to view. This feature can be crucial to some users, letting them be able to monitor data that constantly needs supervision. Log files can roll over as well, which happens when a log file runs out of space. When this occurs, a new empty file with the same name is created to log more data, while the old file that has no more space gets a .bat extension added to the end of the file name. This allows for data to be retained longer before being overwritten. 

To use logging in a software application on the JNIOR, you will need to use the JANOS class of the JANOS runtime library. With it you can define a log file name and what you want to log to it. If the log file exists at the location you specify, it will add what enter to it. If the log file doesn’t exist, it will create the log file, and then log what you enter to it. Below is a short example of creating/adding to a log file that exists in the temp folder of the JNIOR.

View on GitHub

I put the built jar file of this example application into the JNIOR’s flash folder and ran it from the Web UI’s console tab. As you can see after running it, going to the temp directory of the JNIOR shows the loggingExample.log file.

View on GitHub

This post goes over an application that checks the current devices connected to the JNIOR, and if any of them are temperature probes logs there device index and current temperature. 

Log Temperature starts off by declaring a string builder, which will be used later to log our information. We start with a while loop set to true so our program runs unless exited. We then perform a for loop that iterates 10 times. This checks the indexes of devices connected to the JNIOR from 1 – 10. Each time the loop iterates, it checking the JNIOR’s registry for connected temperature probes using the isTempPresent function. This returns the index of a temperature probe connected to the JNIOR. Once the index is returned its then used to get the temperature of that temperature probe, and then uses the string builder to construct a sentence listing time, index, and temperature from the temperature probe. This is then logged to a log file called tempLog.log. The while loop returns re-logging the values every minute.