Use the Logger class to manage log sessions. If the nRF Logger application is not installed on the device, these methods will do nothing.
Creating a session:
- Basic session:
Logger.newSession(context, key, name) - Session with profile:
Logger.newSession(context, "Profile Name", key, name). This creates a folder in nRF Logger by concatenating the profile name with the application name.
Parameters:
key: A non-null string used to group log sessions from the same day together.name: The title shown in the UI. If null, "No name" is displayed.
Session Metadata:
- Add a description:
Logger.setSessionDescription(logSession, "This is a comment") - Mark a session:
Logger.setSessionMark(logSession, Logger.MARK_FLAG_RED)
// Create a session
logSession = Logger.newSession(context, key, name);
// Add entries
Logger.log(logSession, Level.INFO, text);
Logger.e(logSession, R.string.error, someArg);
// Add metadata
Logger.setSessionDescription(logSession, "This is a comment");
Logger.setSessionMark(logSession, Logger.MARK_FLAG_RED);