Skip to main content

Logger API

Command Intents

Applications can send commands to Datalogic Logger through a set of API intents. These intents perform the same actions that are available through the Logger application. They can be useful to issues commands in response to a system event, such as the start of a user login, or the reporting of an error.

To avoid the potential for any application other than Datalogic Logger from processing the Intent, all intents should be created using the following package name for the recipient:

com.datalogic.logger

The available intents with specific details on their behavior are listed below.

Start a Log Session

  • Intent Action: com.datalogic.logger.START_LOG
  • Intent Data: None
  • Intent Extra Data: None

A new log session is started using the existing configuration settings. If the logging service is busy (already running), this command will be ignored.

If this command is issued early during a device reboot, any unsaved log content from a previous session (due to a system crash) will be archived before starting a new session.

Stop a Log Session

  • Intent Action: com.datalogic.logger.STOP_LOG
  • Intent Data: None
  • Intent Extra Data: None

Any current log session is stopped, and an archive file of the log content will be created. If no log session was currently active, this command will be ignored.

Export Latest Log Archive

  • Intent Action: com.datalogic.logger.EXPORT_LOG
  • Intent Data: None
  • Intent Extra Data: Optional
    • Key Name: url
    • Type: String
    • Description: If included, this specifies the server URL to use for exporting the archive. If not included, the existing configuration setting will be used.

The most recent archive on the device will be exported to the server URL specified by the current configuration setting (or the URL specified by the optional extra data in the intent). Any archive that is already queued for export will not be considered in selecting the most recent archive. If no archive exists, this command will be ignored.

If this command is issued early during a device reboot, any unsaved log content from a previous session (due to a system crash) will be archived and then selected to be exported.

Sample code

The following code fragment illustrates how to issue each of the logger intents from an activity.

fun logDemo()
{
val logPackage = "com.datalogic.logger"

// Create/Send intent to start a log session.
val startLog = Intent("com.datalogic.logger.START_LOG")
startLog.setPackage(logPackage)
sendBroadcast(startLog)

// Create/Send intent to stop a log session.
val stopLog = Intent("com.datalogic.logger.STOP_LOG")
stopLog.setPackage(logPackage)
sendBroadcast(stopLog)

// Create/Send intent to export log files to a specific URL.
val exportLog = Intent("com.datalogic.logger.EXPORT_LOG")
val serverUrl = "https://www.myserver.com/logUploads"
exportLog.setPackage(logPackage)
exportLog.putExtra("url", serverUrl)
sendBroadcast(exportLog)
}