Skip to content

Commit d0e71b6

Browse files
new format save between results
1 parent 3949b46 commit d0e71b6

File tree

10 files changed

+102
-44
lines changed

10 files changed

+102
-44
lines changed

core/src/main/java/oracle/weblogic/deploy/logging/SummaryHandler.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.List;
99
import java.util.Properties;
1010
import java.util.logging.ConsoleHandler;
11+
import java.util.logging.Formatter;
1112
import java.util.logging.Handler;
1213
import java.util.logging.Level;
1314
import java.util.logging.LogManager;
@@ -40,6 +41,7 @@ public class SummaryHandler extends MemoryHandler implements WLSDeployLogEndHand
4041

4142
private PlatformLogger LOGGER = WLSDeployLogFactory.getLogger("wlsdeploy.exit");
4243
private boolean recap = false;
44+
private String toolName;
4345
private int bufferSize;
4446

4547
private Handler target;
@@ -53,6 +55,7 @@ public SummaryHandler() {
5355
super();
5456
configure();
5557
target = getConsoleHandler();
58+
target.setFormatter(new SummaryFormatter());
5659
LOGGER.setLevel(Level.INFO);
5760
addLevelHandler(Level.INFO);
5861
addLevelHandler(Level.WARNING);
@@ -135,8 +138,9 @@ public boolean isRecap() {
135138
* @param onlineMode if true, a recap of the log records will be displayed
136139
*/
137140
@Override
138-
public void logEnd(boolean onlineMode) {
141+
public void logEnd(String toolName, boolean onlineMode) {
139142
setRecap(onlineMode);
143+
this.toolName = toolName;
140144
push();
141145
}
142146

@@ -165,6 +169,37 @@ private void addLevelHandler(Level level) {
165169
handler.setFilter(getFilter());
166170
handlers.add(handler);
167171
}
172+
private class SummaryFormatter extends Formatter {
173+
174+
private final String MSG_FORMAT = " %1$5d. %2$s: %3$s" + System.lineSeparator();
175+
private final String INTERNAL = "%s" + System.lineSeparator();
176+
private int sequence = 0;
177+
178+
@Override
179+
public synchronized String format(LogRecord record) {
180+
String message = "";
181+
String msgId = record.getMessage();
182+
if (msgId.indexOf('{') >= 0) {
183+
msgId = null;
184+
}
185+
String formatted = formatMessage(record);
186+
if (msgId != null && !msgId.equals(formatted)) {
187+
// this has a msg id. don't post any that don't have msg id.
188+
if (msgId.startsWith("WLSDPLY-21")) {
189+
message = String.format(INTERNAL, formatted);
190+
} else {
191+
message = String.format(MSG_FORMAT, ++sequence, msgId, formatted);
192+
}
193+
}
194+
return message;
195+
}
196+
197+
@Override
198+
public String getHead(Handler handler) {
199+
return formatMessage(getLogRecord("WLSDPLY-21000", handler.getLevel().getLocalizedName()))
200+
+ System.lineSeparator();
201+
}
202+
}
168203

169204
private class LevelHandler extends MemoryHandler {
170205

core/src/main/java/oracle/weblogic/deploy/logging/WLSDeployLogEndHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public interface WLSDeployLogEndHandler {
2121
/**
2222
* The handler performs any wrap-up action.
2323
*
24+
* @param toolName the name of the tool that is running
2425
* @param online true if the tool is running in online mode.
2526
*/
26-
void logEnd(boolean online);
27+
void logEnd(String toolName, boolean online);
2728

2829
}

core/src/main/java/oracle/weblogic/deploy/util/WLSDeployExit.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@ public class WLSDeployExit {
2828
/**
2929
* Perform any last methods for the tools and exit the JVM.
3030
*
31-
* @param error_code for exit from the JVM.
31+
* @param toolName of tool that is currently running
32+
* @param errorCode for exit from the JVM
3233
* @param online true if the tool ran in online mode
3334
*/
34-
public static void exit(int error_code, boolean online) {
35+
public static void exit(String toolName, int errorCode, boolean online) {
3536
String METHOD = "exit";
3637
LOGGER.entering(CLASS, METHOD, online);
37-
log_cleanup(online);
38+
log_cleanup(toolName, online);
3839
LOGGER.exiting(CLASS, METHOD);
39-
exit(error_code);
40+
exit(errorCode);
4041
}
4142

4243
/**
@@ -52,14 +53,15 @@ public static void exit(int error_code) {
5253
/**
5354
* Call any WLSDeployLogEnd Logger handlers so the handlers can perform end actions.
5455
*
55-
* @param online true if the tool ran in online mode.
56+
* @param toolName name of tool that is currently running
57+
* @param online true if the tool ran in online mode
5658
*/
57-
public static void log_cleanup(boolean online) {
59+
public static void log_cleanup(String toolName, boolean online) {
5860
String METHOD = "log_cleanup";
5961
LOGGER.entering(CLASS, METHOD, online);
6062
Stack<Handler> handlers = reduceList(traverseHandlers(getTopLogList(), new LinkedList<Handler>()));
6163
while (handlers.size() > 0) {
62-
logEnd((WLSDeployLogEndHandler)handlers.pop(), online);
64+
logEnd(toolName, (WLSDeployLogEndHandler)handlers.pop(), online);
6365
}
6466
LOGGER.exiting(CLASS, METHOD);
6567
}
@@ -74,8 +76,8 @@ private static List<Logger> getTopLogList() {
7476
return loggerList;
7577
}
7678

77-
private static synchronized void logEnd(WLSDeployLogEndHandler handler, boolean online) {
78-
handler.logEnd(online);
79+
private static synchronized void logEnd(String toolName, WLSDeployLogEndHandler handler, boolean online) {
80+
handler.logEnd(toolName, online);
7981
}
8082

8183
private static LinkedList<Handler> traverseHandlers(List<Logger> loggers, LinkedList<Handler> handlerList) {

core/src/main/python/create.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,14 @@ def validate_model(model_dictionary, model_context, aliases):
289289
__logger.severe('WLSDPLY-20000', _program_name, ex.getLocalizedMessage(), error=ex,
290290
class_name=_class_name, method_name=_method_name)
291291
__clean_up_temp_files()
292-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
292+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
293+
__wlst_mode == WlstModes.ONLINE)
293294

294295
if return_code == Validator.ReturnCode.STOP:
295296
__logger.severe('WLSDPLY-20001', _program_name, class_name=_class_name, method_name=_method_name)
296297
__clean_up_temp_files()
297-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
298+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
299+
__wlst_mode == WlstModes.ONLINE)
298300

299301

300302
def main(args):
@@ -320,7 +322,7 @@ def main(args):
320322
__logger.severe('WLSDPLY-20008', _program_name, ex.getLocalizedMessage(), error=ex,
321323
class_name=_class_name, method_name=_method_name)
322324
__clean_up_temp_files()
323-
WLSDeployExit.exit(exit_code, __wlst_mode == WlstModes.ONLINE)
325+
WLSDeployExit.exit(None, exit_code, __wlst_mode == WlstModes.ONLINE)
324326

325327
model_file = model_context.get_model_file()
326328
try:
@@ -329,7 +331,8 @@ def main(args):
329331
__logger.severe('WLSDPLY-20009', _program_name, model_file, te.getLocalizedMessage(), error=te,
330332
class_name=_class_name, method_name=_method_name)
331333
__clean_up_temp_files()
332-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
334+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
335+
__wlst_mode == WlstModes.ONLINE)
333336

334337
try:
335338
variable_map = {}
@@ -340,7 +343,8 @@ def main(args):
340343
__logger.severe('WLSDPLY-20004', _program_name, ex.getLocalizedMessage(), error=ex,
341344
class_name=_class_name, method_name=_method_name)
342345
__clean_up_temp_files()
343-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
346+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
347+
__wlst_mode == WlstModes.ONLINE)
344348

345349
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
346350
validate_model(model, model_context, aliases)
@@ -356,12 +360,14 @@ def main(args):
356360
__logger.severe('WLSDPLY-12409', _program_name, ex.getLocalizedMessage(), error=ex,
357361
class_name=_class_name, method_name=_method_name)
358362
__clean_up_temp_files()
359-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
363+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
364+
__wlst_mode == WlstModes.ONLINE)
360365
except DeployException, ex:
361366
__logger.severe('WLSDPLY-12410', _program_name, ex.getLocalizedMessage(), error=ex,
362367
class_name=_class_name, method_name=_method_name)
363368
__clean_up_temp_files()
364-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
369+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
370+
__wlst_mode == WlstModes.ONLINE)
365371

366372
__clean_up_temp_files()
367373
return

core/src/main/python/deploy.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,14 @@ def validate_model(model_dictionary, model_context, aliases):
407407
__logger.severe('WLSDPLY-20000', _program_name, ex.getLocalizedMessage(), error=ex,
408408
class_name=_class_name, method_name=_method_name)
409409
__clean_up_temp_files()
410-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
410+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
411+
__wlst_mode == WlstModes.ONLINE)
411412

412413
if return_code == Validator.ReturnCode.STOP:
413414
__logger.severe('WLSDPLY-20001', _program_name, class_name=_class_name, method_name=_method_name)
414415
__clean_up_temp_files()
415-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
416+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
417+
__wlst_mode == WlstModes.ONLINE)
416418

417419

418420
def main(args):
@@ -438,7 +440,7 @@ def main(args):
438440
__logger.severe('WLSDPLY-20008', _program_name, ex.getLocalizedMessage(), error=ex,
439441
class_name=_class_name, method_name=_method_name)
440442
__clean_up_temp_files()
441-
WLSDeployExit.exit(exit_code, __wlst_mode == WlstModes.ONLINE)
443+
WLSDeployExit.exit(None, exit_code, __wlst_mode == WlstModes.ONLINE)
442444

443445
model_file = model_context.get_model_file()
444446
try:
@@ -447,7 +449,8 @@ def main(args):
447449
__logger.severe('WLSDPLY-09014', _program_name, model_file, te.getLocalizedMessage(), error=te,
448450
class_name=_class_name, method_name=_method_name)
449451
__clean_up_temp_files()
450-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
452+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
453+
__wlst_mode == WlstModes.ONLINE)
451454

452455
try:
453456
variable_map = {}
@@ -458,7 +461,8 @@ def main(args):
458461
__logger.severe('WLSDPLY-20004', _program_name, ex.getLocalizedMessage(), error=ex,
459462
class_name=_class_name, method_name=_method_name)
460463
__clean_up_temp_files()
461-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
464+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
465+
__wlst_mode == WlstModes.ONLINE)
462466

463467
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
464468
validate_model(model_dictionary, model_context, aliases)
@@ -474,7 +478,8 @@ def main(args):
474478
__logger.severe('WLSDPLY-09015', _program_name, ex.getLocalizedMessage(), error=ex,
475479
class_name=_class_name, method_name=_method_name)
476480
__clean_up_temp_files()
477-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
481+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
482+
__wlst_mode == WlstModes.ONLINE)
478483

479484
__clean_up_temp_files()
480485
return

core/src/main/python/discover.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def __check_and_customize_model(model, model_context, aliases):
438438
return model
439439

440440

441-
def __log_and_exit(exit_code, class_name, method_name):
441+
def __log_and_exit(program_name, exit_code, class_name, method_name):
442442
"""
443443
Helper method to log the exiting message and call sys.exit()
444444
:param exit_code: the exit code to use
@@ -447,7 +447,7 @@ def __log_and_exit(exit_code, class_name, method_name):
447447
"""
448448
__logger.exiting(result=exit_code, class_name=class_name, method_name=method_name)
449449

450-
WLSDeployExit.exit(exit_code, __wlst_mode == WlstModes.ONLINE)
450+
WLSDeployExit.exit(program_name, exit_code, __wlst_mode == WlstModes.ONLINE)
451451

452452

453453
def main(args):
@@ -475,14 +475,15 @@ def main(args):
475475
if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
476476
__logger.severe('WLSDPLY-20008', _program_name, ex.getLocalizedMessage(), error=ex,
477477
class_name=_class_name, method_name=_method_name)
478-
__log_and_exit(exit_code, _class_name, _method_name)
478+
__log_and_exit(None, exit_code, _class_name, _method_name)
479479

480480
try:
481481
__clear_archive_file(model_context)
482482
except DiscoverException, ex:
483483
__logger.severe('WLSDPLY-06010', _program_name, model_context.get_archive_file_name(),
484484
ex.getLocalizedMessage(), error=ex, class_name=_class_name, method_name=_method_name)
485-
__log_and_exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name, _method_name)
485+
__log_and_exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name,
486+
_method_name)
486487

487488
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
488489
model = None
@@ -492,7 +493,8 @@ def main(args):
492493
__logger.severe('WLSDPLY-06011', _program_name, model_context.get_domain_name(),
493494
model_context.get_domain_home(), ex.getLocalizedMessage(),
494495
error=ex, class_name=_class_name, method_name=_method_name)
495-
__log_and_exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name, _method_name)
496+
__log_and_exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name,
497+
_method_name)
496498

497499
model = __check_and_customize_model(model, model_context, aliases)
498500

@@ -502,11 +504,12 @@ def main(args):
502504
except TranslateException, ex:
503505
__logger.severe('WLSDPLY-20024', _program_name, model_context.get_archive_file_name(), ex.getLocalizedMessage(),
504506
error=ex, class_name=_class_name, method_name=_method_name)
505-
__log_and_exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name, _method_name)
507+
__log_and_exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name,
508+
_method_name)
506509

507510
__close_archive(model_context)
508511

509-
__log_and_exit(exit_code, _class_name, _method_name)
512+
__log_and_exit(model_context.get_program_name(), exit_code, _class_name, _method_name)
510513

511514
if __name__ == 'main':
512515
WebLogicDeployToolingVersion.logVersionInfo(_program_name)

core/src/main/python/update.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,14 @@ def validate_model(model_dictionary, model_context, aliases):
424424
__logger.severe('WLSDPLY-20000', _program_name, ex.getLocalizedMessage(), error=ex,
425425
class_name=_class_name, method_name=_method_name)
426426
__clean_up_temp_files()
427-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
427+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
428+
__wlst_mode == WlstModes.ONLINE)
428429

429430
if return_code == Validator.ReturnCode.STOP:
430431
__logger.severe('WLSDPLY-20001', _program_name, class_name=_class_name, method_name=_method_name)
431432
__clean_up_temp_files()
432-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
433+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
434+
__wlst_mode == WlstModes.ONLINE)
433435

434436

435437
def main(args):
@@ -455,7 +457,7 @@ def main(args):
455457
__logger.severe('WLSDPLY-20008', _program_name, ex.getLocalizedMessage(), error=ex,
456458
class_name=_class_name, method_name=_method_name)
457459
__clean_up_temp_files()
458-
WLSDeployExit.exit(exit_code, __wlst_mode == WlstModes.ONLINE)
460+
WLSDeployExit.exit(None, exit_code, __wlst_mode == WlstModes.ONLINE)
459461

460462
model_file = model_context.get_model_file()
461463
try:
@@ -464,7 +466,8 @@ def main(args):
464466
__logger.severe('WLSDPLY-09014', _program_name, model_file, te.getLocalizedMessage(), error=te,
465467
class_name=_class_name, method_name=_method_name)
466468
__clean_up_temp_files()
467-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
469+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
470+
__wlst_mode == WlstModes.ONLINE)
468471

469472
try:
470473
variable_map = {}
@@ -475,7 +478,8 @@ def main(args):
475478
__logger.severe('WLSDPLY-20004', _program_name, ex.getLocalizedMessage(), error=ex,
476479
class_name=_class_name, method_name=_method_name)
477480
__clean_up_temp_files()
478-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
481+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
482+
__wlst_mode == WlstModes.ONLINE)
479483

480484
aliases = Aliases(model_context, wlst_mode=__wlst_mode)
481485
validate_model(model_dictionary, model_context, aliases)
@@ -491,7 +495,8 @@ def main(args):
491495
__logger.severe('WLSDPLY-09015', _program_name, ex.getLocalizedMessage(), error=ex,
492496
class_name=_class_name, method_name=_method_name)
493497
__clean_up_temp_files()
494-
WLSDeployExit.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, __wlst_mode == WlstModes.ONLINE)
498+
WLSDeployExit.exit(model_context.get_program_name(), CommandLineArgUtil.PROG_ERROR_EXIT_CODE,
499+
__wlst_mode == WlstModes.ONLINE)
495500

496501
__clean_up_temp_files()
497502
return

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ WLSDPLY-20023={0} unable to add model file {1} to archive as {2}: {3}
12101210
WLSDPLY-20024={0} failed to persist the model to the archive file {1}: {2}
12111211

12121212
# Common messages used for tool exit and clean-up
1213-
WLSDPLY-21000=Recap of {0} messages ********************** :
1213+
WLSDPLY-21000={0} Messages:
12141214
WLSDPLY-21001= {0} total : {1}
12151215
WLSDPLY-21002= Total: {0}
1216+
WLSDPLY-21003=Activity Log for {0}

0 commit comments

Comments
 (0)