hypertrack / hyperlog-android Goto Github PK
View Code? Open in Web Editor NEWUtility logger library for storing logs into database and push them to remote server for debugging
Utility logger library for storing logs into database and push them to remote server for debugging
I believe you can't trust BuildConfig.VERSION_NAME
to return the actual version name defined in build.gradle.
You should maybe update LogFormat to look something like this:
public class LogFormat implements Serializable {
private String deviceUUID;
private String versionName;
public LogFormat(Context context) {
Context mContext = context.getApplicationContext();
deviceUUID = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID);
try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
this.version = pInfo.versionName;
} catch (PackageManager.NameNotFoundException exception) {
this.version = "null";
}
}
And then use this.version
when building the log string.
Can anyone please let me know what is the location of the file in the hyperlog file in the memory system
User should have a possibility to add information about TAG and format message with TAG and send the TAG to a server because many Android devs use tags to recognize a place of logs.
How to append logs in same file without creating new one ?
It would be helpful if one could override the data format that is sent. Currently, it appears that it just joins log records with a line separator. However, if one's logging server accepts json data, that won't necessary work:
[ { ... }, { ... } ]
One could achieve the inner json formatting pretty easily with a custom log formatter, and just pushing a json string, and supplying a formatter which printed the log message only.
It would be helpful to overload the push method to accept some form of joiner, so one could potentially wrap those messages inside of a json array element.
Hi,
I'm pushing the logs on beeceptor.com (since request.bin is closed).
Logs are displayed correctly, and also the header, so the pushing is OK.
I'm trying to send log to our php webserver, but I don't know how to access the filename.
$_POST is empty, $_FILES is empty, file_get_contents('php://input') is empty too.
I can display the headers(in this example i changed the filename to 'gigi'):
App-Id: it.test.app
User-Agent: it.therocks.merchandiser (Android 6.0)
Device-Id: 4ae8e6217abba451
If-Modified-Since: Mon, 23 Apr 2018 17:05:12 GMT+00:00
Content-Disposition: attachment; filename=gigi
Device-Time: 2018-04-23T17:11:58.524Z
Content-Type: multipart/form-data;boundary=HyperLog -1524503518517
Host: acer.therocks.it
Connection: Keep-Alive
Accept-Encoding: gzip
Content-Length: 1049
So my question is: how can I get the content of the logs?
Thanks
I get the following error when trying to push the logs to server using:
HyperLog.pushLogs
onError :: called with :: hlErrorResponse.getErrorCode = [400], hlErrorResponse.getErrorMessage = [400: The request could not be understood by the server due to malformed syntax. Missing boundary header]
Suppose first time I opened the app and navigate through app then kills the app. Logs of this session will be stored on remote server. Now suppose after killing the app, launched the same app again .
So, at this time logs of first session will be available or accessible from database or it will be destroy ?
Hi,
i want to know whether i have to write the above line of code with every custom log in android code or just one time in every activity or fragment.
Basically tell me how this line will create on file if i write logs in different files in different packages.
I've added mavenCentral for other libraries since jcenter is sunsetting, but this is the only library that isn't resolving.
Can you verify the latest version is distributed?
I have NPE when my app call HyperLog.getDeviceLogsInFile.
This is stacktrace:
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: java.lang.IllegalStateException: Couldn't read row 0, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at android.database.CursorWindow.nativeGetString(Native Method)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at android.database.CursorWindow.getString(CursorWindow.java:438)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at com.hypertrack.hyperlog.DeviceLogTable.getDeviceLogs(DeviceLogTable.java:207)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at com.hypertrack.hyperlog.DeviceLogDatabaseHelper.getDeviceLogs(DeviceLogDatabaseHelper.java:117)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at com.hypertrack.hyperlog.DeviceLogList.getDeviceLogs(DeviceLogList.java:54)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at com.hypertrack.hyperlog.HyperLog.getDeviceLogs(HyperLog.java:355)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at com.hypertrack.hyperlog.HyperLog.getDeviceLogs(HyperLog.java:338)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at com.hypertrack.hyperlog.HyperLog.getDeviceLogsInFile(HyperLog.java:487)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at com.hypertrack.hyperlog.HyperLog.getDeviceLogsInFile(HyperLog.java:459)
02-19 21:21:33.625 7736-7736/com.ubikinformatica.it.eteam W/System.err: at com.hypertrack.hyperlog.HyperLog.getDeviceLogsInFile(HyperLog.java:433)
File file = HyperLog.getDeviceLogsInFile(this);
return null always...
Log file is not getting created for Huawei Honor device. Whenever I call
File file = HyperLog.getDeviceLogsInFile(getActivity(), false);
file
is always returning null
.
Hi,
Looks like you have the above attribute in the AndroidManifest. This causes merging problems for those who have apps with allowBackup
set to false. There's a way to get around it using tools:replace
but I'm wondering if there's a need for it on your side (since using tools:replace
effectively ignores it regardless)?
I can quickly open up a PR if needed.
Thanks,
Julien
When use Hyperlog.d or Hyperlog.v to log a message and push to the server, it will use the log level I set globally for level filtering. Other log levels are ok.
`
File file =
HyperLog.getDeviceLogsInFile(this);
HyperLog.setURL("url");
HyperLog.pushLogs(this, file.getAbsolutePath(), false, new HLCallback() {
@Override
public void onSuccess(@NonNull Object response) {
Log.d("HYPERLOG", "onSuccess: called");
}
@Override
public void onError(@NonNull HLErrorResponse HLErrorResponse) {
Log.d("HYPERLOG", "onError: called");
MiscUtilities.sendErrorReportToCrashAnalytics("onErrorCalled"+HLErrorResponse.getErrorCode());
}
});`
i am sending the data like this but not all the data is being sent to the server why is that ??
can anyone help ???
Because in a project I'm using timber - and I don't want change all methods call, my proposition creates a small library which will connect hyperlog and timber. I just implement Timber.Tree.
Hi,
I want to update same log file as soon as new logs are added in code.
I dont want to write entire logs at same time but want it to write time to time.
Is it possible?
Regards,
Priyanka
Automatic deletion mechanism of old logs is broken. It is based on incorrect assumption, that each log line should start with a time stamp like 2017-10-05T14:46:36.541Z, and chooses logs to delete by simple string comparison of whole log line and string made from date before which logs should be deleted.
This causes two major problems:
It took me a long search to find why all my logs starting with custom date "dd/mm" are removed between Hyperlog initializations - it was simply because it made log lines start with '0', while string made from date before which logs should be deleted always started with '2'.
A weakreference is incorrectly used to access the success callback.
When the application's memory usage increases or if the device's memory is limited, this reference get Garbage-Collected and callback is never called.
I am getting an exception when HyperLog.pushLogs reaches the onSuccess
Thanks for the great library.
We are moving away from our custom remote logger to hyperlog. Our old backend was not able to support the new request of hyperlog.
One thing we observed was the boundary mismatch.
In headers we observed
('Content-Type', 'multipart/form-data;boundary=HyperLog -1520361605154')
which was coming from the java code
private final String boundary = "HyperLog -" + System.currentTimeMillis();
But the request's body didn't have the timeinmillis part in the boundary.
'--HyperLog\r\nContent-Disposition: form-data; name="<ngx_upload_module_dummy>"\r\n\r\n\r\n--HyperLog--\r\n'
We got the error line as
Invalid multipart/form-data: no final boundary
We wanted to cross check with you guys whether there is any issue from the library.
Currently the logs are cleared after an expiry time (default of 7 days).
I'd be more interested in restricting the total disk consumption rather than some arbitrary time limit.
Hi!
I am using this library and it works fine but when I change the expiry period of logs in this way, it is not working:
HyperLog.initialize(Constants.appContext, 172800, new CustomLogMessageFormat(this)); // 2 days
Is there any other change that I have to do??
Thanks in advance!
Hi there!
I got a few crash reports with this issue "Unable to create application: sqlite.SQLiteDatabaseLockedException: database is locked" initializing HyperLog library.
The initialization code is situated in an extension of Application class and looks like this:
HyperLog.initialize(this, 3 * LockerData.LIMIT_MAX); // default 3 days
if (BuildConfig.DEBUG_MODE) {
HyperLog.setLogLevel(Log.DEBUG);
} else {
HyperLog.setLogLevel(Log.ASSERT);
}
Here is a full crash log from Firebase:
Caused by android.database.sqlite.SQLiteDatabaseLockedException
database is locked (code 5): , while compiling: PRAGMA journal_mode ################################################################# Error Code : 5 (SQLITE_BUSY) Caused By : The database file is locked. (database is locked (code 5): , while compiling: PRAGMA journal_mode) #################################################################android.database.sqlite.SQLiteConnection.nativePrepareStatement (SQLiteConnection.java)
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:163)
com.hypertrack.hyperlog.DeviceLogDatabaseHelper.initializeDatabase (DeviceLogDatabaseHelper.java:53)
com.hypertrack.hyperlog.DeviceLogDatabaseHelper. (DeviceLogDatabaseHelper.java:48)
com.hypertrack.hyperlog.DeviceLogDatabaseHelper.getInstance (DeviceLogDatabaseHelper.java:60)
com.hypertrack.hyperlog.HyperLog.initialize (HyperLog.java:128)
com.hypertrack.hyperlog.HyperLog.initialize (HyperLog.java:96)
com.myapp.app.MyApplication.onCreate (MyApplication.java:160)
android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1032)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
Please advice, what can be done here to fix the issue? Is it some issue of the library itself or a misplaced configuration?
The problem is that in a class that implements Thread.UncaughtExceptionHandler, after calling the method pushLogs(), it is never reached onSuccess() or onError().
Thanks.
Hi
Are the maintainers still supporting this project ?
Is there a replacement library for this project ?
Seems this project is now discontinued :-/
How to change log file name present its saving as with timestamp format 2019_11_07T06_56_34.128Z.txt. I want to save with different names.
can anyone suggest??
The library is using api 27 as target and it includes support library 27, so if you try to use a project with api 28, gradle complains that you are using two different versions. Please update to api 28.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.