Giter Site home page Giter Site logo

hypertrack / hyperlog-android Goto Github PK

View Code? Open in Web Editor NEW
690.0 57.0 109.0 3.33 MB

Utility logger library for storing logs into database and push them to remote server for debugging

Java 100.00%
android logger android-library logs log-management java server-push requestbin debugging android-debug

hyperlog-android's People

Contributors

adaok avatar amanjain08 avatar arjunattam avatar deniszpua avatar piyushgupta27 avatar shivamzxzx avatar thenishchalraj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyperlog-android's Issues

Version name always returns 1.0

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.

Location of the file

Can anyone please let me know what is the location of the file in the hyperlog file in the memory system

Missing TAG in formatLogMessage method

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.

Format for sending data

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.

Get the file using PHP

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

Missing boundary header

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]

Logs Accessibility from database: On killing and then relaunching app

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 ?

Not found on mavenCentral()?

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?

NPE when calling HyperLog.getDeviceLogsInFile

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)

Log file is not getting created

Log file is not getting created for Huawei Honor device. Whenever I call

File file = HyperLog.getDeviceLogsInFile(getActivity(), false);

file is always returning null.

android:allowBackup="true" attribute in Manifest causes problems

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

All logs are not being sent to the server only some chunks of data is being sent .!!!

`

  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 ???

Create connector between Hyperlog and Timber

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.

Update log file timely

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 is broken

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:

  • if there's no such time stamp, old logs won't be ever automatically deleted
  • logs starting with strings "lower" than string made from date before which logs should be deleted are automatically deleted.

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'.

Success callback not called due to weakreference

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.

Is the Boundary headers right?

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.

Allow size limit rather than time limit

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.

expiryTime not change

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!

Unable to create application: sqlite.SQLiteDatabaseLockedException: database is locked

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?

Project status ?

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 ?

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??

Impossible to compile with api 28

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.