Skip to content

Commit ca675ad

Browse files
committed
Added more log-levels ready to use;
Added option to display a project name from where the log came from.
1 parent ff55e43 commit ca675ad

8 files changed

Lines changed: 103 additions & 42 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target/
22
/.idea/
3+
/src/test/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Simple logger for java with mixpanel support
66
<dependency>
77
<groupId>io.github.Fi0x</groupId>
88
<artifactId>JavaLogger</artifactId>
9-
<version>1.2.1</version>
9+
<version>1.3.0</version>
1010
</dependency>
1111
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.Fi0x</groupId>
88
<artifactId>JavaLogger</artifactId>
9-
<version>1.2.1</version>
9+
<version>1.3.0</version>
1010
<name>Java Logger</name>
1111
<description>This is a Library for a custom Java Logger</description>
1212
<url>http://github.com/Fi0x/JavaLogger</url>

src/main/java/io/fi0x/javalogger/logging/LogEntry.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class LogEntry
2626
boolean consoleException = false;
2727
boolean mixpanel = false;
2828
String mixpanelEventName = "LOG";
29+
String projectName = "JavaLogger";
2930

3031
/**
3132
* Create a new {@link LogEntry} with the given text.
@@ -61,6 +62,7 @@ public LogEntry(String text, String templateName) throws IllegalArgumentExceptio
6162
this.consoleException = t.consoleException;
6263
this.mixpanel = t.mixpanelMessage;
6364
this.mixpanelEventName = t.mixpanelEventName;
65+
this.projectName = t.projectName;
6466
}
6567
public LogEntry(String text, Enum<?> templateName) throws IllegalArgumentException
6668
{
@@ -216,4 +218,15 @@ public LogEntry MIXPANELNAME(String mixpanelEvent)
216218
mixpanelEventName = mixpanelEvent;
217219
return this;
218220
}
221+
/**
222+
* Change the name of the project that produces this {@link LogEntry}.
223+
* @param nameOfProject The project name under which this {@link LogEntry} should be displayed
224+
* (Default is 'JavaLogger').
225+
* @return The current {@link LogEntry} to be used further.
226+
*/
227+
public LogEntry PROJECTNAME(String nameOfProject)
228+
{
229+
projectName = nameOfProject;
230+
return this;
231+
}
219232
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.fi0x.javalogger.logging;
2+
3+
public enum LogLevel
4+
{
5+
VERBOSE,
6+
VVERBOSE,
7+
VVVERBOSE,
8+
INFO,
9+
WARNING,
10+
ERROR,
11+
SPECIAL,
12+
RESPONSE,
13+
QUESTION,
14+
CLEAN_INFO,
15+
CLEAN_SPECIAL,
16+
CLEAN_RESPONSE,
17+
CLEAN_QUESTION
18+
}

src/main/java/io/fi0x/javalogger/logging/LogTemplate.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ class LogTemplate
1717
boolean consoleException;
1818
boolean mixpanelMessage;
1919
String mixpanelEventName;
20+
String projectName;
2021

21-
LogTemplate(String color, String background, String level, boolean writeToFile, boolean requireVerbose, int verboseLevel, boolean requireDebug, boolean noPrefix, boolean showExceptionInConsole, boolean mixpanelMessage, String mixpanelEventName)
22+
LogTemplate(String color, String background, String level, boolean writeToFile, boolean requireVerbose, int verboseLevel, boolean requireDebug, boolean noPrefix, boolean showExceptionInConsole, boolean mixpanelMessage, String mixpanelEventName, String projectName)
2223
{
2324
this.color = color;
2425
this.background = background;
@@ -31,5 +32,6 @@ class LogTemplate
3132
this.consoleException = showExceptionInConsole;
3233
this.mixpanelMessage = mixpanelMessage;
3334
this.mixpanelEventName = mixpanelEventName;
35+
this.projectName = projectName;
3436
}
3537
}

src/main/java/io/fi0x/javalogger/logging/Logger.java

Lines changed: 63 additions & 36 deletions
Large diffs are not rendered by default.

src/main/java/io/fi0x/javalogger/mixpanel/MixpanelHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static boolean addMessage(String eventName, Map<String, String> propertie
5959
if(eventName == null || userID == null || projectToken == null)
6060
{
6161
LogEntry l = new LogEntry("Could not add Mixpanel-event to queue. Name, UserID or ProjectToken is null")
62-
.COLOR(LogColor.RED)
62+
.COLOR(LogColor.RED_BRIGHT)
6363
.LEVEL("ERR")
6464
.CODE(0)
6565
.FILE_ENTRY(false);
@@ -75,7 +75,7 @@ public static boolean addMessage(String eventName, Map<String, String> propertie
7575
if(MIXPANEL_PROPERTIES.contains(prop.toLowerCase(Locale.ROOT)))
7676
{
7777
LogEntry l = new LogEntry("Could not add Mixpanel-event to queue. Property '" + prop + "' is a property mixpanel uses itself")
78-
.COLOR(LogColor.RED)
78+
.COLOR(LogColor.RED_BRIGHT)
7979
.LEVEL("ERR")
8080
.CODE(0)
8181
.FILE_ENTRY(false);
@@ -182,7 +182,7 @@ private static void startUploaderThread()
182182
if(e != null)
183183
{
184184
LogEntry l = new LogEntry("Could not upload a Mixpanel delivery")
185-
.COLOR(LogColor.RED)
185+
.COLOR(LogColor.RED_BRIGHT)
186186
.LEVEL("ERR")
187187
.CODE(0)
188188
.EXCEPTION(e)

0 commit comments

Comments
 (0)