Log

This is a simple log print utils, like android.util.Log.

License

License

Categories

Categories

Net
GroupId

GroupId

net.mm2d.log
ArtifactId

ArtifactId

log-android
Last Version

Last Version

0.9.4
Release Date

Release Date

Type

Type

aar
Description

Description

Log
This is a simple log print utils, like android.util.Log.
Project URL

Project URL

https://github.com/ohmae/log
Source Code Management

Source Code Management

https://github.com/ohmae/log

Download log-android

How to add to project

<!-- https://jarcasting.com/artifacts/net.mm2d.log/log-android/ -->
<dependency>
    <groupId>net.mm2d.log</groupId>
    <artifactId>log-android</artifactId>
    <version>0.9.4</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/net.mm2d.log/log-android/
implementation 'net.mm2d.log:log-android:0.9.4'
// https://jarcasting.com/artifacts/net.mm2d.log/log-android/
implementation ("net.mm2d.log:log-android:0.9.4")
'net.mm2d.log:log-android:aar:0.9.4'
<dependency org="net.mm2d.log" name="log-android" rev="0.9.4">
  <artifact name="log-android" type="aar" />
</dependency>
@Grapes(
@Grab(group='net.mm2d.log', module='log-android', version='0.9.4')
)
libraryDependencies += "net.mm2d.log" % "log-android" % "0.9.4"
[net.mm2d.log/log-android "0.9.4"]

Dependencies

runtime (2)

Group / Artifact Type Version
net.mm2d.log : log jar 0.9.4
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.30

Project Modules

There are no modules declared in this project.

Log

license GitHub release GitHub issues GitHub closed issues Maven Central

This is a simple log print utils, like android.util.Log.

log

The "log" module is written in kotlin and can be used anywhere in Java / Kotlin projects.

log-android

The "log-android" module is a utility for using the "log" module on Android.

Requirements

  • log

    • Java SE 7 or later
  • log-android

    • Android API Level 14 (Android 4.0.0) or later

And I strongly recommend to use with Lambda. (Kotlin, Java8, desugar, retrolambda, etc.)

Example of use

Initialize

This library needs to set Log Level. Default is never output log. And needs to specify a Sender. Default does nothing.

If you use the default implementation, write as follows.

private val DEBUG = true
private val VERBOSE = true
...
if (DEBUG) {
    Logger.setLogLevel(Logger.VERBOSE)
    Logger.setSender(Senders.create())
    Senders.appendCaller(VERBOSE)
    Senders.appendThread(VERBOSE)
}

for Android

If you write it like this, you can output log to Logcat. (default is System.out)

private val VERBOSE = true
...
if (BuildConfig.DEBUG) {
    Logger.setLogLevel(Logger.VERBOSE)
    Logger.setSender(AndroidSenders.create())
    AndroidSenders.appendCaller(VERBOSE)
    AndroidSenders.appendThread(VERBOSE)
}

Custom sender

Of course you can implement Sender any way. e.g. write to a file or send it to the network, etc.

Logger.setSender {level, message, throwable ->
    ...
}

If you want to use same format as the default, please try the following:

Logger.setSender(DefaultSender.create { level, tag, message ->
    ...
})

Log Level

If you set the log level, logs that are equal to or higher than the set value are output.

ASSERT > ERROR > WARN > INFO > DEBUG > VERBOSE

eg. If you set Log.ERROR

Logger.setLogLevel(Log.ERROR)

Only ASSERT or ERROR level logs are output.

logging

Logger.v("verbose")
Logger.d("debug")
Logger.i("info")
Logger.w("warning")
Logger.e("error")

Output

Logger.setLogLevel(Logger.VERBOSE)
Logger.setSender(Senders.create())
2018-02-24 05:02:05.510 V [MainWindow] verbose
2018-02-24 05:02:05.510 D [MainWindow] debug
2018-02-24 05:02:05.510 I [MainWindow] info
2018-02-24 05:02:05.510 W [MainWindow] warning
2018-02-24 05:02:05.510 E [MainWindow] error
Logger.setLogLevel(Logger.VERBOSE)
Logger.setSender(Senders.create())
Senders.appendCaller(true)
Senders.appendThread(true)
2018-02-24 05:02:46.541 V [MainWindow] [main,5,main] net.mm2d.upnp.sample.MainWindow.main(MainWindow.java:57) : verbose
2018-02-24 05:02:46.542 D [MainWindow] [main,5,main] net.mm2d.upnp.sample.MainWindow.main(MainWindow.java:58) : debug
2018-02-24 05:02:46.542 I [MainWindow] [main,5,main] net.mm2d.upnp.sample.MainWindow.main(MainWindow.java:59) : info
2018-02-24 05:02:46.542 W [MainWindow] [main,5,main] net.mm2d.upnp.sample.MainWindow.main(MainWindow.java:60) : warning
2018-02-24 05:02:46.542 E [MainWindow] [main,5,main] net.mm2d.upnp.sample.MainWindow.main(MainWindow.java:61) : error

How to use

jCenter will close in May. In 0.9.4 moved to mavenCentral from jcenter.
Please note that the groupID has changed

Download from mavenCentral. Maven Central

Add dependencies, as following.

dependencies {
    implementation("net.mm2d.log:log:0.9.4")
}

If use with Android utils, as following.

dependencies {
    implementation("net.mm2d.log:log:0.9.4")
    implementation("net.mm2d.log:log-android:0.9.4")
}

Versions below 0.9.4 were distributed with jCenter. However, jCenter will close and old versions are not migrated to mavenCentral. If you need an older version, please use the Github Pages repository.

repositories {
    maven { url = URI("https://ohmae.github.com/maven") }
}
dependencies {
    implementation("net.mm2d:log:0.9.3")
    implementation("net.mm2d:log-android:0.9.3")
}

Dependent OSS

  • Kotlin
    • org.jetbrains.kotlin:kotlin-stdlib

Author

大前 良介 (OHMAE Ryosuke) http://www.mm2d.net/

License

MIT License

Versions

Version
0.9.4