This is a wrap for this Github-Project.
ExternalLogger
External logger library for android applications. You can save logs
in any component in your app (Activity, Service, Fragment). The data
will be stored in memory even after exiting the application or
turning off the device. You can access the information at any time,
export the data to an email, to a text file or to a server.
The data can be accessed by the tag filter, text, or log creation
time. The data will be deleted by a function under your control.
Author: DonManfred
Version: 0.1
- Add this code to your Mainmodule to include the needed AAR and the dependency for the Room-Database Runtime.
- Add this code to your Starter Service
You now easily can add a LOG-Entry from anywhere in your Project.
In this case the Entry is using the Tag "AppStart". You can use any String you like. You´ll be able to get the logs based on the Tag, Datetime range...
ExternalLogger
External logger library for android applications. You can save logs
in any component in your app (Activity, Service, Fragment). The data
will be stored in memory even after exiting the application or
turning off the device. You can access the information at any time,
export the data to an email, to a text file or to a server.
The data can be accessed by the tag filter, text, or log creation
time. The data will be deleted by a function under your control.
Author: DonManfred
Version: 0.1
- ExtLog
- Functions:
- Initialize (tag As String, text As String)
- IsInitialized As Boolean
- Initialize (tag As String, text As String)
- Properties:
- Obj As ExtLog [read only]
- Tag As String
- Text As String
- Time As Long
- Uid As Int
- Obj As ExtLog [read only]
- Functions:
- ExternalLogger
- Events:
- logsReturned (logs As List)
- onCompleted()
- Functions:
- addLogToDB (extLog As guy4444.extrnalloggerlibrary.ExtLog)
- addLogToDB2 (tag As String, text As String)
- deleteAll
- getAllLogsBetweenDates (start As Long, end As Long, loggerDBCallBack_logsReturned As guy4444.extrnalloggerlibrary.MyLoggerDB.LoggerDBCallBack_LogsReturned)
- getAllLogsByTag (tag As String)
- getAllLogsByTagAndText (tag As String, text As String)
- getAllLogsByTagAndTextBetweenDates (start As Long, end As Long, tag As String, text As String)
- getAllLogsByTagAndTextFromDate (start As Long, tag As String, text As String)
- getAllLogsByTagBetweenDates (start As Long, end As Long, tag As String)
- getAllLogsByTagFromDate (start As Long, tag As String)
- getAllLogsFromDate (start As Long, loggerDBCallBack_logsReturned As guy4444.extrnalloggerlibrary.MyLoggerDB.LoggerDBCallBack_LogsReturned)
- Initialize (EventName As String)
- addLogToDB (extLog As guy4444.extrnalloggerlibrary.ExtLog)
- Properties:
- AllLogs [read only]
- AllLogs [read only]
- Events:
- Add this code to your Mainmodule to include the needed AAR and the dependency for the Room-Database Runtime.
B4X:
#AdditionalJar: externallogger.aar
#AdditionalJar: android.arch.persistence.room:runtime
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public extLog As ExternalLogger
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
extLog.Initialize("ExtLog")
End Sub
Sub AddLOG(tag, text As String)
Log($"ExtLOG(${tag},${text})"$)
extLog.addLogToDB2(tag, text)
End Sub
Sub AddLOG2(tag, text As String)
Log($"ExtLOG2(${tag},${text})"$)
Dim logitem As ExtLog
logitem.Initialize(tag,text)
logitem.Time = DateTime.Now
extLog.addLogToDB(logitem)
End Sub
Sub ExtLog_logsReturned(logs As List)
Log($"ExtLog_logsReturned(${logs})"$)
For i=0 To logs.Size-1
Dim l As ExtLog = logs.Get(i)
Log($"ExtLOG: $datetime{l.Time}: ${l.Text}, ${l.Tag}"$)
Next
End Sub
Sub ExtLog_onCompleted()
Log($"ExtLog_onCompleted()"$)
End Sub
You now easily can add a LOG-Entry from anywhere in your Project.
B4X:
CallSub3(Starter,"AddLOG","AppStart",$"This is the Text to LOG (FirstTime = ${FirstTime})"$)
In this case the Entry is using the Tag "AppStart". You can use any String you like. You´ll be able to get the logs based on the Tag, Datetime range...
B4X:
Starter.extLog.getAllLogsByTag("AppStart")
Attachments
Last edited: