-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The most important thing: A cool logo
Put '0:play.modules.logger.RePlayLogoPlugin' in your play.plugins and let the magic happen! To use your own logo just check the sources for hint and create your own LogoPlugin!
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 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,40 @@ | ||
package play.modules.logger; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import play.PlayPlugin; | ||
import play.exceptions.UnexpectedException; | ||
|
||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Objects; | ||
|
||
public class RePlayLogoPlugin extends PlayPlugin { | ||
private static final Logger logger = LoggerFactory.getLogger(RePlayLogoPlugin.class); | ||
|
||
|
||
/** | ||
* The most important thing: A cool logo. | ||
*/ | ||
private static final String REPLAY_LOGO = "\n" + | ||
" ______ ______ _ _\n" + | ||
" / / / / _ __ ___ _ __ | | __ _ _ _| |\n" + | ||
" / / / / | '_ / -_) '_ \\| |/ _' | || |_|\n" + | ||
" / / / / |_/ \\___| __/|_|\\____|\\__ (_)\n" + | ||
"/_____/ /_____/ |_| |__/\n" + | ||
" RePlay Framework {}, https://github.com/codeborne/replay\n"; | ||
|
||
private static final String REPLAY_VERSION_LOCATION = "play/version"; | ||
|
||
private String readReplayVersion() { | ||
try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(REPLAY_VERSION_LOCATION)) { | ||
return new String(Objects.requireNonNull(stream).readAllBytes(), StandardCharsets.UTF_8).trim(); | ||
} catch (Exception e) { | ||
throw new UnexpectedException("Something is wrong with your build. Cannot find resource " + REPLAY_VERSION_LOCATION); | ||
} | ||
} | ||
@Override | ||
public void onApplicationStart() { | ||
logger.info(REPLAY_LOGO, readReplayVersion()); | ||
} | ||
} |
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