Skip to content

Commit

Permalink
1 - Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lixa4-m committed Jul 29, 2020
1 parent bbf775b commit 98b8500
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 2 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 SantaSpeen
Copyright (c) 2020 Maxim Khomutov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 22 additions & 0 deletions Logger.java
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;}

}
30 changes: 30 additions & 0 deletions Logger.kts
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
}
}
55 changes: 54 additions & 1 deletion README.md
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)

0 comments on commit 98b8500

Please sign in to comment.