本文整理汇总了Java中org.springframework.shell.support.logging.HandlerUtils类的典型用法代码示例。如果您正苦于以下问题:Java HandlerUtils类的具体用法?Java HandlerUtils怎么用?Java HandlerUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HandlerUtils类属于org.springframework.shell.support.logging包,在下文中一共展示了HandlerUtils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HandleHelp
import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
private InterpreterResult HandleHelp(JLineShell shell, String st) {
java.util.logging.StreamHandler sh = null;
java.util.logging.Logger springLogger = null;
java.util.logging.Formatter formatter = new java.util.logging.Formatter() {
public String format(java.util.logging.LogRecord record) {
return record.getMessage();
}
};
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
sh = new java.util.logging.StreamHandler(baos, formatter);
springLogger = HandlerUtils.getLogger(org.springframework.shell.core.SimpleParser.class);
springLogger.addHandler(sh);
shell.executeCommand(st);
} catch (Exception e) {
s_logger.error(e.getMessage(), e);
return new InterpreterResult(Code.ERROR, e.getMessage());
}
finally {
sh.flush();
springLogger.removeHandler(sh);
sh.close();
}
return new InterpreterResult(Code.SUCCESS, baos.toString());
}
示例2: main
import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
public static void main(String[] args) {
SpringApplication application = new SpringApplication(Application.class);
application.setAdditionalProfiles("local");
try {
BootShim bs = new BootShim(args, application.run(args));
bs.run();
} catch (RuntimeException e) {
throw e;
} finally {
HandlerUtils.flushAllHandlers(Logger.getLogger(""));
}
}
示例3: main
import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(DemoApplication.class, args);
try {
BootShim bs = new BootShim(args,ctx);
bs.run();
} catch (RuntimeException e) {
throw e;
} finally {
HandlerUtils.flushAllHandlers(Logger.getLogger(""));
}
}
示例4: setupLogging
import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
private void setupLogging() {
Logger rootLogger = Logger.getLogger("");
HandlerUtils.wrapWithDeferredLogHandler(rootLogger, Level.SEVERE);
Logger sfwLogger = Logger.getLogger("org.springframework");
sfwLogger.setLevel(Level.WARNING);
Logger rooLogger = Logger.getLogger("org.springframework.shell");
rooLogger.setLevel(Level.FINE);
}
示例5: doRun
import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
private ExitShellRequest doRun() {
this.stopWatch.start();
try {
String[] commandsToExecuteAndThenQuit = this.commandLine.getShellCommandsToExecute();
ExitShellRequest exitShellRequest;
if (null != commandsToExecuteAndThenQuit) {
boolean successful = false;
exitShellRequest = ExitShellRequest.FATAL_EXIT;
for (String cmd : commandsToExecuteAndThenQuit) {
if (!(successful = this.lineShellComponent.executeCommand(cmd).isSuccess()))
break;
}
if (successful) {
exitShellRequest = ExitShellRequest.NORMAL_EXIT;
}
}
else if (this.applicationArguments.containsOption("help")) {
System.out.println(FileUtils.readBanner(ShellCommandLineRunner.class, "/usage.txt"));
exitShellRequest = ExitShellRequest.NORMAL_EXIT;
} else {
this.lineShellComponent.start();
this.lineShellComponent.promptLoop();
exitShellRequest = this.lineShellComponent.getExitShellRequest();
if (exitShellRequest == null) {
exitShellRequest = ExitShellRequest.NORMAL_EXIT;
}
this.lineShellComponent.waitForComplete();
}
if (this.lineShellComponent.isDevelopmentMode()) {
System.out.println("Total execution time: " + this.stopWatch
.getLastTaskTimeMillis() + " ms");
}
return exitShellRequest;
} catch (Exception ex) {
throw new ShellException(ex.getMessage(), ex);
} finally {
HandlerUtils.flushAllHandlers(this.logger);
this.stopWatch.stop();
}
}
示例6: doRun
import org.springframework.shell.support.logging.HandlerUtils; //导入依赖的package包/类
private ExitShellRequest doRun() {
this.stopWatch.start();
try {
String[] commandsToExecuteAndThenQuit = this.commandLine.getShellCommandsToExecute();
ExitShellRequest exitShellRequest;
if (null != commandsToExecuteAndThenQuit) {
boolean successful = false;
exitShellRequest = ExitShellRequest.FATAL_EXIT;
for (String cmd : commandsToExecuteAndThenQuit) {
if (!(successful = this.lineShellComponent.executeCommand(cmd).isSuccess()))
break;
}
if (successful) {
exitShellRequest = ExitShellRequest.NORMAL_EXIT;
}
}
else if (this.applicationArguments.containsOption("help")) {
System.out.println(FileUtils.readBanner(ShellCommandLineRunner.class, "/usage.txt"));
exitShellRequest = ExitShellRequest.NORMAL_EXIT;
}
else {
this.lineShellComponent.start();
this.lineShellComponent.promptLoop();
exitShellRequest = this.lineShellComponent.getExitShellRequest();
if (exitShellRequest == null) {
exitShellRequest = ExitShellRequest.NORMAL_EXIT;
}
this.lineShellComponent.waitForComplete();
}
if (this.lineShellComponent.isDevelopmentMode()) {
System.out.println("Total execution time: " + this.stopWatch.getLastTaskTimeMillis() + " ms");
}
return exitShellRequest;
}
catch (Exception ex) {
throw new ShellException(ex.getMessage(), ex);
}
finally {
HandlerUtils.flushAllHandlers(this.logger);
this.stopWatch.stop();
}
}