-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
492a716
commit 8de9993
Showing
12 changed files
with
116 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package dev.latvian.apps.webutils.ansi; | ||
|
||
import dev.latvian.apps.webutils.TimeUtils; | ||
|
||
import java.util.Date; | ||
|
||
public class Log { | ||
public enum Type { | ||
INFO, | ||
WARN, | ||
ERROR, | ||
DEBUG, | ||
SUCCESS, | ||
FAIL, | ||
IMPORTANT, | ||
CODE | ||
} | ||
|
||
public static Log INSTANCE = new Log(); | ||
|
||
public static void info(Object message) { | ||
INSTANCE.log(Type.INFO, Ansi.of(message)); | ||
} | ||
|
||
public static void warn(Object message) { | ||
INSTANCE.log(Type.WARN, Ansi.of(message).yellow()); | ||
} | ||
|
||
public static void error(Object message) { | ||
INSTANCE.log(Type.ERROR, Ansi.of(message).error()); | ||
} | ||
|
||
public static void debug(Object message) { | ||
INSTANCE.log(Type.DEBUG, Ansi.of(message).lightGray()); | ||
} | ||
|
||
public static void success(Object message) { | ||
INSTANCE.log(Type.SUCCESS, Ansi.of(message).green()); | ||
} | ||
|
||
public static void fail(Object message) { | ||
INSTANCE.log(Type.FAIL, Ansi.of(message).red()); | ||
} | ||
|
||
public static void success(Object message, boolean success) { | ||
if (success) { | ||
success(message); | ||
} else { | ||
fail(message); | ||
} | ||
} | ||
|
||
public static void important(Object message) { | ||
INSTANCE.log(Type.IMPORTANT, Ansi.of(message).orange()); | ||
} | ||
|
||
public static void code(Object message) { | ||
INSTANCE.log(Type.CODE, Ansi.of(message).teal()); | ||
} | ||
|
||
public void log(Type type, AnsiComponent message) { | ||
var now = new Date(); | ||
var c = Ansi.of(); | ||
c.append(Ansi.cyan(TimeUtils.formatDate(new StringBuilder(), now).toString())); | ||
c.append(' '); | ||
c.append(message); | ||
System.out.println(c); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
src/test/java/dev/latvian/apps/webutils/test/XMLTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
package dev.latvian.apps.webutils.test; | ||
|
||
import dev.latvian.apps.webutils.ansi.Ansi; | ||
import dev.latvian.apps.webutils.ansi.Log; | ||
import dev.latvian.apps.webutils.html.XMLParser; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class XMLTests { | ||
@Test | ||
public void xml() { | ||
var xml = XMLParser.parse(""" | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<note> | ||
<!--Comment--> | ||
<to>Tove</to> | ||
<from when="yesterday">Jani</from> | ||
<heading>Reminder</heading> | ||
<body a="b"c="d">Don't <b>forget</b> me this weekend!</body> | ||
</note>""", false); | ||
Ansi.log("XML:\n" + xml.toAnsi(true)); | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<note> | ||
<!--Comment--> | ||
<to>Tove</to> | ||
<from when="yesterday">Jani</from> | ||
<heading>Reminder</heading> | ||
<body a="b"c="d">Don't <b>forget</b> me this weekend!</body> | ||
</note>""", false); | ||
Log.info("XML:\n" + xml.toAnsi(true)); | ||
} | ||
} |