-
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
Showing
4 changed files
with
107 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
public class Logger { | ||
|
||
private final String module; | ||
|
||
public Logger(String module){ | ||
this.module = module; | ||
} | ||
|
||
public String getTime() { | ||
SimpleDateFormat formatForDateNow = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SS"); | ||
return formatForDateNow.format(new Date()); | ||
} | ||
|
||
public Logger core(String text){System.out.println("\033[34m["+getTime()+" CORE]: \033[35m["+this.module+"]\033[0m \033[34m" + text + "\033[0m"); return this;} | ||
public Logger info(String text){System.out.println("\033[32m["+getTime()+" INFO]\033[0m: \033[35m[" + this.module + "]\033[0m " + text); return this;} | ||
public Logger warn(String text){System.out.println("\033[33m\033[5m["+getTime()+" WARN]\033[0m: \033[35m[" + this.module + "]\033[0m " + text); return this;} | ||
public Logger error(String text){System.out.println("\033[31m\033[6m["+getTime()+" ERROR]\033[0m:\033[35m[" + this.module + "]\033[0m " + text); return this;} | ||
|
||
} |
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,30 @@ | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
class Logger(private val module: String) { | ||
val time: String | ||
get() { | ||
val formatForDateNow = SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SS") | ||
return formatForDateNow.format(Date()) | ||
} | ||
|
||
fun core(text: String): Logger { | ||
println("\u001b[34m[$time CORE]: \u001b[35m[$module]\u001b[0m \u001b[34m$text\u001b[0m") | ||
return this | ||
} | ||
|
||
fun info(text: String): Logger { | ||
println("\u001b[32m[$time INFO]\u001b[0m: \u001b[35m[$module]\u001b[0m $text") | ||
return this | ||
} | ||
|
||
fun warn(text: String): Logger { | ||
println("\u001b[33m\u001b[5m[$time WARN]\u001b[0m: \u001b[35m[$module]\u001b[0m $text") | ||
return this | ||
} | ||
|
||
fun error(text: String): Logger { | ||
println("\u001b[31m\u001b[6m[$time ERROR]\u001b[0m:\u001b[35m[$module]\u001b[0m $text") | ||
return this | ||
} | ||
} |
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 +1,54 @@ | ||
# Logger.Java | ||
# Logger for Java | ||
|
||
<p align="center"> | ||
<img src="https://img.shields.io/github/license/SantaSpeen/Logger.Java?style=for-the-badge"> | ||
<img src="https://img.shields.io/github/issues/SantaSpeen/Logger.Java?style=for-the-badge"> | ||
</p> | ||
|
||
### Installing | ||
|
||
* Download this repo | ||
* Init in your project | ||
|
||
### Usage | ||
Java: | ||
```java | ||
import Logger; | ||
|
||
class main{ | ||
private static final Logger LOG = new Logger("Module name"); | ||
|
||
public static void main(String[] args) { | ||
LOG.core("Logger: Core"); | ||
LOG.info("Logger: Info"); | ||
LOG.warn("Logger: Warn"); | ||
LOG.error("Logger: Error"); | ||
} | ||
|
||
} | ||
``` | ||
Kotlin: | ||
```kotlin | ||
import Logger | ||
|
||
class main{ | ||
var LOG = Logger("Module name") | ||
|
||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
LOG.core("Logger: Core") | ||
LOG.info("Logger: Info") | ||
LOG.warn("Logger: Warn") | ||
LOG.error("Logger: Error") | ||
} | ||
} | ||
|
||
``` | ||
|
||
### Links! | ||
|
||
- [Python](python.org) | ||
|
||
- [Link to this project](https://github.com/SantaSpeen/Logger.Java) | ||
|
||
- [Author](https://vk.com/id370926160) |