Skip to content

Commit ed768c5

Browse files
authored
Merge pull request #1 from tamayok/master
1.0.1
2 parents ea4a8b8 + ca9e7ed commit ed768c5

11 files changed

Lines changed: 34 additions & 33 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tealium Library for Java Version 1.0.0
1+
# Tealium Library for Java
22

33
This mobile library leverages the power of Tealium's [AudienceStream™](http://tealium.com/products/audiencestream/) making them natively available to Java applications.
44

@@ -21,7 +21,8 @@ The Tealium AudienceStream™ Influence DMP (data management platform) enables y
2121
* If you have **account specific questions** please contact your Tealium account manager
2222

2323
## Change Log
24-
24+
- 1.0.1 Bug Fix
25+
- LogLevel enum converted to public API
2526
- 1.0.0 Initial Release
2627
- Tealium universal data sources added for all dispatches:
2728
- event_name (transitionary - will be deprecated)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.tealium</groupId>
55
<artifactId>java</artifactId>
6-
<version>1.0.0</version>
6+
<version>1.0.1</version>
77
<name>TealiumJava</name>
88

99
<packaging>jar</packaging>

src/main/java/com/tealium/DataManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public DataManager(LibraryContext libraryContext) {
5252
} catch (IOException e) {
5353
// File must be corrupt/unreadable etc
5454
this.persistentCache = new HashMap<>();
55-
this.context.getLogger().log(e, Logger.Level.ERRORS);
55+
this.context.getLogger().log(e, LogLevel.ERRORS);
5656
}
5757
}
5858

src/main/java/com/tealium/FileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static final void deletePersistentFile(LibraryContext context) {
4949
file = FileUtils.getPersistentFile(context);
5050
file.delete();
5151
} catch (IOException e) {
52-
context.getLogger().log(e, Logger.Level.ERRORS);
52+
context.getLogger().log(e, LogLevel.ERRORS);
5353
}
5454
}
5555

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.tealium;
2+
3+
public enum LogLevel {
4+
NONE(3), ERRORS(2), WARNINGS(1), VERBOSE(0);
5+
6+
private final int priority;
7+
8+
private LogLevel(int priority) {
9+
this.priority = priority;
10+
}
11+
12+
int getPriority() {
13+
return priority;
14+
}
15+
}

src/main/java/com/tealium/Logger.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,20 @@
1010
*/
1111
final class Logger {
1212

13-
static enum Level {
14-
NONE(3), ERRORS(2), WARNINGS(1), VERBOSE(0);
15-
16-
private final int priority;
17-
18-
private Level(int priority) {
19-
this.priority = priority;
20-
}
21-
22-
int getPriority() {
23-
return priority;
24-
}
25-
};
26-
27-
private final Level level;
13+
private final LogLevel level;
2814
private final PrintStream out;
2915

30-
public Level getLevel() {
16+
public LogLevel getLevel() {
3117
return level;
3218
}
3319

34-
public Logger(Level level) {
20+
public Logger(LogLevel level) {
3521
super();
3622
this.level = level;
3723
out = System.out;
3824
}
3925

40-
public boolean isLogging(Level level) {
26+
public boolean isLogging(LogLevel level) {
4127
return level.getPriority() >= this.level.getPriority();
4228
}
4329

@@ -49,13 +35,13 @@ public boolean isLogging(Level level) {
4935
* @param level
5036
* Level of message.
5137
*/
52-
public void log(String message, Level level) {
38+
public void log(String message, LogLevel level) {
5339
if (isLogging(level)) {
5440
out.println(message);
5541
}
5642
};
5743

58-
public void log(Throwable t, Level level) {
44+
public void log(Throwable t, LogLevel level) {
5945
if (isLogging(level)) {
6046
out.println(t);
6147
t.printStackTrace(out);

src/main/java/com/tealium/Tealium.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static class Builder {
2727
private final String account;
2828
private final String profile;
2929
private final String environment;
30-
private Logger.Level logLevel = Logger.Level.VERBOSE;
30+
private LogLevel logLevel = LogLevel.VERBOSE;
3131
private int timeout = 5000;
3232

3333
/**
@@ -58,7 +58,7 @@ public Tealium build() {
5858
this.timeout);
5959
}
6060

61-
public Builder setLogLevel(Logger.Level level) {
61+
public Builder setLogLevel(LogLevel level) {
6262
if (level == null) {
6363
throw new IllegalArgumentException("Invalid log level.");
6464
}
@@ -168,7 +168,7 @@ public void track(String eventTitle, Map<String, ?> data, Tealium.DispatchCallba
168168
try {
169169
this.collect.dispatch(contextData, callback);
170170
} catch (IOException e) {
171-
this.libraryContext.getLogger().log(e, Logger.Level.ERRORS);
171+
this.libraryContext.getLogger().log(e, LogLevel.ERRORS);
172172
}
173173
}
174174

src/test/java/com/tealium/DataManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void testNewPersistentData() throws Exception {
9292
String account = "account";
9393
String profile = "profile";
9494
String env = "env";
95-
LibraryContext ctx = new LibraryContext(account, profile, env, new Logger(Logger.Level.VERBOSE));
95+
LibraryContext ctx = new LibraryContext(account, profile, env, new Logger(LogLevel.VERBOSE));
9696
FileUtils.deletePersistentFile(ctx);
9797

9898
DataManager data = new DataManager(ctx);

src/test/java/com/tealium/LoggerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
public class LoggerTest {
66
@Test
77
public void test() throws Exception{
8-
new Logger(Logger.Level.VERBOSE).log("Hello Test", Logger.Level.VERBOSE);
8+
new Logger(LogLevel.VERBOSE).log("Hello Test", LogLevel.VERBOSE);
99
}
1010
}

src/test/java/com/tealium/TealiumTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import org.junit.Test;
99

10-
import com.tealium.Logger.Level;
1110
import com.tealium.Tealium.DispatchCallback;
1211

1312
public class TealiumTest {
@@ -20,7 +19,7 @@ public void testTealiumInit() throws Exception {
2019
@Test
2120
public void testTealiumInitWithLogLevel() throws Exception {
2221
new Tealium.Builder("tealiummobile", "main", "dev")
23-
.setLogLevel(Level.WARNINGS)
22+
.setLogLevel(LogLevel.WARNINGS)
2423
.build();
2524

2625
}

0 commit comments

Comments
 (0)