GithubHelp home page GithubHelp logo

treessence's People

Contributors

bastienpaulfr avatar cepages avatar deronbrown avatar ericksorto 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

Watchers

 avatar  avatar

treessence's Issues

FileLoggerTree doesn't print anything lower than ERROR

Firstly thanks for your code, It's great!

Secondly I found that the logger doesn't print in the file anything lower than ERROR.

I fixed this setting the level in the logger.

        logger.setLevel(fromPriorityToLevel(priority));

I added it in the FileLoggerTree constructor.

Do you think it's a bug, or I'm missing something.

If it's a bug, I'm happy to open a pull request :)

List<Filter>.mergeFilters() is not adding filters to MergeFilter object

fun List<Filter>.mergeFilters() = when {
    this.isEmpty() -> NoFilter.INSTANCE
    this.size == 1 -> this[0]
    else -> MergeFilter().apply {
        this.filters.addAll(filters)
    }
}

at line 29

this.filters.addAll(`filters`)

parameter filters is referencing filters of MergeFilter class, but not filters we want to add. This can be fixed with:

this.filters.addAll(this@mergeFilters)

java.nio.file.FileSystemException: log.0.lck: Read-only file system

I am trying to implement file logging into my app, but the library couldn't create log file

 try {
     Timber.Tree fileTree = new FileLoggerTree.Builder()
           .withFileLimit(5)
           .withMinPriority(Log.DEBUG)
           .appendToFile(true)
           .build();

     Timber.plant(fileTree);
  } catch (IOException e) {
     e.printStackTrace();
  }
W/System.err: java.nio.file.FileSystemException: log.0.lck: Read-only file system
W/System.err:     at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:177)
W/System.err:     at java.nio.channels.FileChannel.open(FileChannel.java:287)
W/System.err:     at java.nio.channels.FileChannel.open(FileChannel.java:335)
W/System.err:     at java.util.logging.FileHandler.openFiles(FileHandler.java:460)
W/System.err:     at java.util.logging.FileHandler.<init>(FileHandler.java:403)
W/System.err:     at fr.bipi.tressence.file.FileLoggerTree$Builder.build(FileLoggerTree.java:242)
W/System.err:     at com.myapp.Application.onCreate(Application.java:23)
W/System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189)
W/System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6867)
W/System.err:     at android.app.ActivityThread.access$1600(ActivityThread.java:242)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7830)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1040)

Crash when setting up File Logger Tree

Hello, this library has been successfully integrated into our app.

However, according to Firebase Crashlytics, a few users encountered the issue below. We are unable to duplicate the same problem though. Here is the stack trace:

Caused by java.io.IOException: Couldn't get lock for /data/user/0/app_name/files/error_log/01_09_2023%g.txt at java.util.logging.FileHandler.openFiles(FileHandler.java:439) at java.util.logging.FileHandler.<init>(FileHandler.java:403) at .. at .. at .. at .. at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190) at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7184) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7134) at android.app.ActivityThread.access$1600(ActivityThread.java:274) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2102) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:8167) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Devices are Oppo, Samsung, Vivo
image

Any help would be appreciated. Thank you!

Extending FileLoggerTree with custom Formatter

Hi there, nice lib.
My issue is that I couldn't find a nice way to supply a custom Formatter to the FileLoggerTree. I had to subclass it including builder and then set it in the constructor. Did I miss something or is it a good idea for improvement?

Could not find dependency

I think it started today, could you check it please?

Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.github.bastienpaulfr:Treessence:1.0.5.

Could not find com.github.bastienpaulfr:Treessence:1.0.5.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/bastienpaulfr/Treessence/1.0.5/Treessence-1.0.5.pom
- https://repo.maven.apache.org/maven2/com/github/bastienpaulfr/Treessence/1.0.5/Treessence-1.0.5.pom

Error planting SystemLogTree

I'm trying to log elements to a txt file (which works perfectly) and also to my IDE logcat. But I cannot plant the SystemLogTree.

WhatsApp Image 2023-01-26 at 09 47 22

FileSystemException: Invalid Argument

I have a crash showing up in Crashlytics:

Fatal Exception: java.lang.RuntimeException
Unable to create application com.companyname.app.AppName: java.nio.file.FileSystemException: /data/user/0/com.companyname.app/files/logs/ApplicationLog0.txt.lck: Invalid argument

It looks like sometimes Treessence is trying to read lck files, instead of just txt files.

crash before OS 7

java.lang.RuntimeException: Unable to create application : java.io.IOException: fcntl failed: EAGAIN (Try again)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at android.app.ActivityThread.access$1600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.io.IOException: fcntl failed: EAGAIN (Try again)
at java.nio.FileChannelImpl.basicLock(FileChannelImpl.java:123)
at java.nio.FileChannelImpl.tryLock(FileChannelImpl.java:181)
at java.nio.channels.FileChannel.tryLock(FileChannel.java:584)
at java.util.logging.FileHandler.initOutputFiles(FileHandler.java:197)
at java.util.logging.FileHandler.init(FileHandler.java:159)
at java.util.logging.FileHandler.(FileHandler.java:482)
at fr.bipi.tressence.file.FileLoggerTree$Builder.build(FileLoggerTree.java:242)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.access$1600(ActivityThread.java:150) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: android.system.ErrnoException: fcntl failed: EAGAIN (Try again)
at libcore.io.Posix.fcntlFlock(Native Method)
at libcore.io.ForwardingOs.fcntlFlock(ForwardingOs.java:70)
at java.nio.FileChannelImpl.basicLock(FileChannelImpl.java:121)
at java.nio.FileChannelImpl.tryLock(FileChannelImpl.java:181) 
at java.nio.channels.FileChannel.tryLock(FileChannel.java:584) 
at java.util.logging.FileHandler.initOutputFiles(FileHandler.java:197) 
at java.util.logging.FileHandler.init(FileHandler.java:159) 
at java.util.logging.FileHandler.(FileHandler.java:482) 
at fr.bipi.tressence.file.FileLoggerTree$Builder.build(FileLoggerTree.java:242) 
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707) 
at android.app.ActivityThread.access$1600(ActivityThread.java:150) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

Device's Timezone information is getting lost

Hi,

thx for these usefuls trees. However, I've discovered that Treessence (specifically the helper method timestampToDate() in TimeUtils) set the JVM's default Timezone hardcoded to UTC.

This means after the first log statement has been logged through Treessence the original timezone that was set by the user is lost!

Crash on newer android OS-es

 Caused by: java.nio.file.FileSystemException: fileg.log.0.lck: Read-only file system
    at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:177)
    at java.nio.channels.FileChannel.open(FileChannel.java:287)
    at java.nio.channels.FileChannel.open(FileChannel.java:335)
    at java.util.logging.FileHandler.openFiles(FileHandler.java:460)
    at java.util.logging.FileHandler.<init>(FileHandler.java:403)

Force write to file

It looks like the moment when FileLoggerTree write logs to a file is undetermined. For example, in my app, it may take hours or days. I actually added Treessence to my app only for one reason - in order to users could attach logs to bug reports. But for some reason, Treessence delays writing to file.

Could you please add the ability to force writing to file?

Timezone Issues Again

Hello. Just started using your library for file logging and am getting all times as US.
I use this in New Zealand.
Can we get some form of timezone setting please. (ZoneId.of("NST"))

Crash

Hello Bastien

Your lib is crashing:

at fr.bipi.tressence.file.FileLoggerTree$Builder.build(FileLoggerTree.java:242)

with

java.nio.file.NoSuchFileException

I think you are using wrong paths, it should be the Apps file dir obtained from getFilesDir()

br, Nik

Please find the stacktrace attached
stacktrace.txt

Crash

2022-03-15 13:50:28.187 20169-20169/com.vavaparty.app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.vavaparty.app, PID: 20169
    java.lang.RuntimeException: Unable to create application com.vavaparty.app.App: java.nio.file.FileSystemException: log.0.lck: Read-only file system
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6855)
        at android.app.ActivityThread.access$1400(ActivityThread.java:246)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:236)
        at android.app.ActivityThread.main(ActivityThread.java:7879)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
     Caused by: java.nio.file.FileSystemException: log.0.lck: Read-only file system
        at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:177)
        at java.nio.channels.FileChannel.open(FileChannel.java:287)
        at java.nio.channels.FileChannel.open(FileChannel.java:335)
        at java.util.logging.FileHandler.openFiles(FileHandler.java:460)
        at java.util.logging.FileHandler.<init>(FileHandler.java:403)
        at fr.bipi.tressence.file.FileLoggerTree$Builder.build(FileLoggerTree.kt:242)
        at com.vavaparty.app.App.onCreate(App.kt:36)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1193)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6850)
        at android.app.ActivityThread.access$1400(ActivityThread.java:246) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1955) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:236) 
        at android.app.ActivityThread.main(ActivityThread.java:7879) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) 

Wrong file name when `withFileLimit` is 1

When using this setup:

FileLoggerTree.Builder()
            .withFileName("logFileName")
            .withDir(androidContext().cacheDir)
            .withMinPriority(Log.VERBOSE)
            .withFileLimit(1)
            .build()

the fileLoggerTree.files will always return an empty list. This happens because fileLoggerTree.getFileName(X) returns the file name appended with ".X" number, but the real file name is without ".X".
For example, with the setup from the above, the library will create a file with the name "logFileName", but the getFileName(0) function will return the "logFileName.0" value, which is incorrect,

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.