加了一个logo输出类

This commit is contained in:
wqh 2017-11-07 19:28:33 +08:00
parent 78c09ef671
commit 5769cb3a3e
2 changed files with 48 additions and 9 deletions

View File

@ -18,6 +18,7 @@ import org.nutz.boot.config.impl.PropertiesConfigureLoader;
import org.nutz.boot.env.SystemPropertiesEnvHolder;
import org.nutz.boot.ioc.IocLoaderProvider;
import org.nutz.boot.resource.ResourceLoader;
import org.nutz.boot.resource.StaredLogoLoaderDD;
import org.nutz.boot.resource.impl.SimpleResourceLoader;
import org.nutz.ioc.Ioc2;
import org.nutz.ioc.IocLoader;
@ -90,16 +91,8 @@ public class NbApp {
if (!Strings.isBlank(logAdapter)) {
Logs.setAdapter((LogAdapter) ctx.getClassLoader().loadClass(logAdapter).newInstance());
}
StaredLogoLoaderDD.printLogo();
log = Logs.get();
log.debug(" \n" +
" _ \n" +
" ____ _ _ _| |_ _____ \n" +
"| _ \\| | | (_ _(___ )\n" +
"| | | | |_| | | |_ / __/ \n" +
"|_| |_|____/ \\__(_____)\n" +
" " +
"\n:: Nutz Boot :: "+ Nutz.version()+"\n");
// 资源加载器
if (ctx.getResourceLoader() == null) {
ResourceLoader resourceLoader = new SimpleResourceLoader();

View File

@ -0,0 +1,46 @@
package org.nutz.boot.resource;
import org.nutz.Nutz;
import org.nutz.boot.resource.impl.SimpleResourceLoader;
import org.nutz.log.Logs;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* NB启动时的LOGO加载类
*
* @Author 蛋蛋-wqh
* @Date 2017年11月7日 19:04:42
*/
public class StaredLogoLoaderDD {
public static void printLogo(){
try {
String str = "\n \n _ _ _ \n" +
" | \\ | | _ _ _| |_ ____\n" +
" | \\| || | | |_| __||_ /\n" +
" | |\\ || |_| | | |_ / / \n" +
" |_| \\_| \\__,_| \\__|/___|" +
"\n:: Nutz Boot :: ("+ Nutz.version()+")\n";
InputStream inputStream = new SimpleResourceLoader().get("banner.txt");
if(inputStream!=null){
str = "";
try (BufferedInputStream bi = new BufferedInputStream(inputStream)) {
byte[] buf = new byte[1024];
int read = 0;
while((read = bi.read(buf))!=-1){
str+=new String(buf,"utf-8");
}
str+="\n:: Nutz Boot :: ("+ Nutz.version()+")\n";
}
}
Logs.get().debug(str);
} catch (IOException e) {
e.printStackTrace();
}
}
}