Skip to content

Commit 6b867dc

Browse files
committed
custom logger
1 parent 9497f09 commit 6b867dc

File tree

4 files changed

+13
-36
lines changed

4 files changed

+13
-36
lines changed

RELEASE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Old signature: `Transaction#fromEncoded(String hexString, Class<T extends Operation> cls)`,
1212
new: `Transaction#fromEncoded(String hexString)`
1313
- Reduced android dependencies, more pure java for JRE support (in future)
14+
- Custom logger
1415

1516
## 0.2.0
1617
- BREAKING CHANGES:

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ dependencies {
170170

171171
// testing
172172
testImplementation 'junit:junit:4.12'
173-
testImplementation 'com.jakewharton.timber:timber:4.7.1'
174173
androidTestImplementation "com.android.support:support-annotations:${minterLibSupport}"
175174
androidTestImplementation 'com.android.support.test:runner:1.0.2'
176175
androidTestImplementation 'com.android.support.test:rules:1.0.2'

src/androidTest/java/network/minter/blockchain/models/BaseApiTest.java

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
import org.junit.Before;
3333

3434
import network.minter.core.MinterSDK;
35-
import timber.log.Timber;
35+
import network.minter.core.internal.log.Mint;
36+
import network.minter.core.internal.log.StdLogger;
3637

3738
/**
3839
* MinterWallet. 2018
@@ -43,27 +44,7 @@ public class BaseApiTest {
4344
static {
4445
MinterSDK.initialize();
4546
//noinspection ConstantConditions
46-
Timber.plant(new Timber.DebugTree() {
47-
@Override
48-
protected void log(int priority, String tag, String message, Throwable t) {
49-
if (message.length() < 4000) {
50-
System.out.println(String.format("[%d]%s: %s", priority, tag, message));
51-
return;
52-
}
53-
54-
// Split by line, then ensure each line can fit into Log's maximum length.
55-
for (int i = 0, length = message.length(); i < length; i++) {
56-
int newline = message.indexOf('\n', i);
57-
newline = newline != -1 ? newline : length;
58-
do {
59-
int end = Math.min(newline, i + 4000);
60-
String part = message.substring(i, end);
61-
System.out.println(String.format("[%d]%s: %s", priority, tag, part));
62-
i = end;
63-
} while (i < newline);
64-
}
65-
}
66-
});
47+
Mint.brew(new StdLogger());
6748
}
6849

6950
private Gson mGson;

src/main/java/network/minter/blockchain/MinterBlockChainApi.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@
4343
import network.minter.core.internal.api.converters.BytesDataDeserializer;
4444
import network.minter.core.internal.api.converters.MinterAddressDeserializer;
4545
import network.minter.core.internal.api.converters.MinterHashDeserializer;
46+
import network.minter.core.internal.log.Mint;
47+
import network.minter.core.internal.log.TimberLogger;
4648
import okhttp3.logging.HttpLoggingInterceptor;
4749

4850
/**
4951
* minter-android-blockchain. 2018
50-
*
5152
* @author Eduard Maximovich <edward.vstock@gmail.com>
5253
*/
5354
public class MinterBlockChainApi {
54-
private final static String BASE_NODE_URL = BuildConfig.BASE_NODE_URL;
55+
private final static String BASE_NODE_URL = BuildConfig.BASE_NODE_URL;
5556
private static MinterBlockChainApi INSTANCE;
5657
private final ApiService.Builder mApiService;
5758
private BlockChainAccountRepository mAccountRepository;
@@ -70,14 +71,17 @@ private MinterBlockChainApi(@Nonnull String baseNodeApiUrl) {
7071
}
7172

7273
public static void initialize() {
73-
initialize(BASE_NODE_URL, false);
74+
initialize(BASE_NODE_URL, false, new TimberLogger());
7475
}
7576

76-
public static void initialize(String baseNodeApiUrl, boolean debug) {
77+
public static void initialize(String baseNodeApiUrl, boolean debug, Mint.Leaf logger) {
7778
if (INSTANCE != null) {
7879
return;
7980
}
8081

82+
if (debug) {
83+
Mint.brew(logger);
84+
}
8185
INSTANCE = new MinterBlockChainApi(baseNodeApiUrl);
8286
INSTANCE.mApiService.setDebug(debug);
8387
if (debug) {
@@ -86,15 +90,7 @@ public static void initialize(String baseNodeApiUrl, boolean debug) {
8690
}
8791

8892
public static void initialize(boolean debug) {
89-
if (INSTANCE != null) {
90-
return;
91-
}
92-
93-
INSTANCE = new MinterBlockChainApi();
94-
INSTANCE.mApiService.setDebug(debug);
95-
if (debug) {
96-
INSTANCE.mApiService.setDebugRequestLevel(HttpLoggingInterceptor.Level.BODY);
97-
}
93+
initialize(BASE_NODE_URL, debug, new TimberLogger());
9894
}
9995

10096
public static MinterBlockChainApi getInstance() {

0 commit comments

Comments
 (0)