Skip to content

Commit f4b6e21

Browse files
adding deprecation log level for deprecation messages to show up in the summary handler (#1369)
1 parent 981297b commit f4b6e21

File tree

15 files changed

+106
-25
lines changed

15 files changed

+106
-25
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2023, Oracle Corporation and/or its affiliates.
3+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
*/
5+
package oracle.weblogic.deploy.logging;
6+
7+
import java.util.logging.Level;
8+
9+
public class DeprecationLevel extends Level {
10+
public static final Level DEPRECATION = new DeprecationLevel("DEPRECATION", 850);
11+
12+
protected DeprecationLevel(String name, int value) {
13+
super(name, value);
14+
}
15+
}

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ public void config(String msg, Object... params) {
6666
logger.logp(Level.CONFIG, details.clazz, details.method, msg, params);
6767
}
6868
}
69+
70+
public void deprecation(String msg, Object... params) {
71+
if (isDeprecationEnabled()) {
72+
CallerDetails details = inferCaller();
73+
logger.logp(DeprecationLevel.DEPRECATION, details.clazz, details.method, msg, params);
74+
}
75+
}
6976

7077
/**
7178
* Logs a method entry. The calling class and method names will be inferred.
@@ -303,16 +310,25 @@ public void info(String msg, Object... params) {
303310
/**
304311
* Checks if a message at CONFIG level would actually be logged.
305312
*
306-
* @return whether or not the CONFIG level is enabled
313+
* @return whether the CONFIG level is enabled
307314
*/
308315
public boolean isConfigEnabled() {
309316
return logger.isLoggable(Level.CONFIG);
310317
}
311318

319+
/**
320+
* Checks if a message at DEPRECATION level would actually be logged.
321+
*
322+
* @return whether the DEPRECATION level is enabled
323+
*/
324+
public boolean isDeprecationEnabled() {
325+
return logger.isLoggable(DeprecationLevel.DEPRECATION);
326+
}
327+
312328
/**
313329
* Checks if a message at FINE level would actually be logged.
314330
*
315-
* @return whether or not the FINE level is enabled
331+
* @return whether the FINE level is enabled
316332
*/
317333
public boolean isFineEnabled() {
318334
return logger.isLoggable(Level.FINE);
@@ -321,7 +337,7 @@ public boolean isFineEnabled() {
321337
/**
322338
* Checks if a message at FINER level would actually be logged.
323339
*
324-
* @return whether or not the FINER level is enabled
340+
* @return whether the FINER level is enabled
325341
*/
326342
public boolean isFinerEnabled() {
327343
return logger.isLoggable(Level.FINER);
@@ -330,7 +346,7 @@ public boolean isFinerEnabled() {
330346
/**
331347
* Checks if a message at FINEST level would actually be logged.
332348
*
333-
* @return whether or not the FINEST level is enabled
349+
* @return whether the FINEST level is enabled
334350
*/
335351
public boolean isFinestEnabled() {
336352
return logger.isLoggable(Level.FINEST);
@@ -339,7 +355,7 @@ public boolean isFinestEnabled() {
339355
/**
340356
* Checks if a message at INFO level would actually be logged.
341357
*
342-
* @return whether or not the INFO level is enabled
358+
* @return whether the INFO level is enabled
343359
*/
344360
@SuppressWarnings("unused")
345361
public boolean isInfoEnabled() {
@@ -350,7 +366,7 @@ public boolean isInfoEnabled() {
350366
* Checks if a message at the provided level would actually be logged.
351367
*
352368
* @param level the logging level to check
353-
* @return whether or not the specified logging level is enabled
369+
* @return whether the specified logging level is enabled
354370
*/
355371
public boolean isLoggable(Level level) {
356372
return logger.isLoggable(level);
@@ -359,7 +375,7 @@ public boolean isLoggable(Level level) {
359375
/**
360376
* Checks if a message at SEVERE level would actually be logged.
361377
*
362-
* @return whether or not the SEVERE level is enabled
378+
* @return whether the SEVERE level is enabled
363379
*/
364380
public boolean isSevereEnabled() {
365381
return logger.isLoggable(Level.SEVERE);
@@ -368,7 +384,7 @@ public boolean isSevereEnabled() {
368384
/**
369385
* Checks if a message at WARNING level would actually be logged.
370386
*
371-
* @return whether or not the WARNING level is enabled
387+
* @return whether the WARNING level is enabled
372388
*/
373389
@SuppressWarnings("unused")
374390
public boolean isWarningEnabled() {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public class StderrFilter implements Filter {
1818
public boolean isLoggable(LogRecord logRecord) {
1919
boolean stdErr = false;
2020
int level = logRecord.getLevel() == null ? 0 : logRecord.getLevel().intValue();
21-
if (level == Level.WARNING.intValue() || level == Level.SEVERE.intValue()) {
21+
if (level == DeprecationLevel.DEPRECATION.intValue() ||
22+
level == Level.WARNING.intValue() ||
23+
level == Level.SEVERE.intValue()) {
2224
stdErr = true;
2325
}
2426
return stdErr;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public class StdoutFilter implements Filter {
1717
public boolean isLoggable(LogRecord logRecord) {
1818
boolean stdOut = true;
1919
int level = logRecord.getLevel() == null ? 0 : logRecord.getLevel().intValue();
20-
if (level == Level.WARNING.intValue() || level == Level.SEVERE.intValue()) {
20+
if (level == DeprecationLevel.DEPRECATION.intValue() ||
21+
level == Level.WARNING.intValue() ||
22+
level == Level.SEVERE.intValue()) {
2123
stdOut = false;
2224
}
2325
return stdOut;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public SummaryHandler() {
5959

6060
this.bufferSize = getMemoryBufferSize(CLASS + SIZE_PROPERTY);
6161

62+
addLevelHandler(DeprecationLevel.DEPRECATION);
6263
addLevelHandler(Level.WARNING);
6364
addLevelHandler(Level.SEVERE);
6465
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class ExitCode {
1111
public static final int ARG_VALIDATION_ERROR = 98;
1212
public static final int USAGE_ERROR = 99;
1313
public static final int HELP = 100;
14+
public static final int DEPRECATION = 101;
1415
public static final int RESTART_REQUIRED = 103;
1516
public static final int CANCEL_CHANGES_IF_RESTART = 104;
1617

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4410,7 +4410,7 @@ protected void extractWallet(File domainHome, String extractPath, List<String> z
44104410
File extractToLocation = domainHome;
44114411
if (!StringUtils.isEmpty(deprecationKey)) {
44124412
extractToLocation = new File(domainHome, WLSDPLY_ARCHIVE_BINARY_DIR);
4413-
LOGGER.warning(deprecationKey, getArchiveFileName(), zipEntry, extractPath);
4413+
LOGGER.deprecation(deprecationKey, getArchiveFileName(), zipEntry, extractPath);
44144414
}
44154415
if (StringUtils.isEmpty(fromDir) && StringUtils.isEmpty(toDir)) {
44164416
extractFileFromZip(zipEntry, extractToLocation);

core/src/main/python/wlsdeploy/logging/platform_logger.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import java.util.logging.Logger as JLogger
1212
import java.util.logging.LogRecord as JLogRecord
1313

14+
import oracle.weblogic.deploy.logging.DeprecationLevel as DeprecationLevel
15+
1416
import wlsdeploy.exception.exception_helper as exception_helper
1517
import wlsdeploy.util.unicode_helper as str_helper
1618

@@ -56,6 +58,9 @@ def is_config_enabled(self):
5658
"""
5759
return self.logger.isLoggable(JLevel.CONFIG)
5860

61+
def is_deprecation_enabled(self):
62+
return self.logger.isLoggable(DeprecationLevel.DEPRECATION)
63+
5964
def is_severe_enabled(self):
6065
"""
6166
Is severe-level logging enabled?
@@ -119,6 +124,14 @@ def config(self, message, *args, **kwargs):
119124
record = self._get_log_record(JLevel.CONFIG, clazz, method, message, error, *args)
120125
self.logger.log(record)
121126

127+
def deprecation(self, message, *args, **kwargs):
128+
method = kwargs.pop('method_name', None)
129+
clazz = kwargs.pop('class_name', None)
130+
error = kwargs.pop('error', None)
131+
record = self._get_log_record(DeprecationLevel.DEPRECATION, clazz, method, message, error, *args)
132+
self.logger.log(record)
133+
134+
122135
def log(self, level, message, *args, **kwargs):
123136
"""
124137
Log a message at the specified level.

core/src/main/python/wlsdeploy/tool/create/rcudbinfo_helper.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ def get_atp_default_tablespace(self):
127127
_method_name = 'get_atp_default_tablespace'
128128
result = self._get_dictionary_element_value(ATP_DEFAULT_TABLESPACE)
129129
if result is not None:
130-
self._logger.warning('WLSDPLY-22000', ATP_DEFAULT_TABLESPACE, RCU_DEFAULT_TBLSPACE,
131-
class_name=_class_name, method_name=_method_name)
130+
self._logger.deprecation('WLSDPLY-22000', ATP_DEFAULT_TABLESPACE, RCU_DEFAULT_TBLSPACE,
131+
class_name=_class_name, method_name=_method_name)
132132
return result
133133
elif self.get_rcu_default_tablespace() is not None:
134134
return self.get_rcu_default_tablespace()
@@ -139,8 +139,8 @@ def get_atp_temporary_tablespace(self):
139139
_method_name = 'get_atp_temp_tablespace'
140140
result = self._get_dictionary_element_value(ATP_TEMPORARY_TABLESPACE)
141141
if result is not None:
142-
self._logger.warning('WLSDPLY-22000', ATP_TEMPORARY_TABLESPACE, RCU_TEMP_TBLSPACE,
143-
class_name=_class_name, method_name=_method_name)
142+
self._logger.deprecation('WLSDPLY-22000', ATP_TEMPORARY_TABLESPACE, RCU_TEMP_TBLSPACE,
143+
class_name=_class_name, method_name=_method_name)
144144
return result
145145
elif self.get_rcu_temp_tablespace() is not None:
146146
return self.get_rcu_temp_tablespace()
@@ -151,8 +151,8 @@ def get_atp_admin_user(self):
151151
_method_name = 'get_atp_admin_user'
152152
result = self._get_dictionary_element_value(ATP_ADMIN_USER)
153153
if result is not None:
154-
self._logger.warning('WLSDPLY-22000', ATP_ADMIN_USER, RCU_DB_USER,
155-
class_name=_class_name, method_name=_method_name)
154+
self._logger.deprecation('WLSDPLY-22000', ATP_ADMIN_USER, RCU_DB_USER,
155+
class_name=_class_name, method_name=_method_name)
156156
return result
157157
elif self.get_rcu_db_user() is not None:
158158
return self.get_rcu_db_user()
@@ -220,8 +220,8 @@ def is_use_atp(self):
220220
_method_name = 'is_use_atp'
221221
result = self._get_dictionary_element_value(USE_ATP)
222222
if result is not None:
223-
self._logger.warning('WLSDPLY-22000', USE_ATP, DATABASE_TYPE,
224-
class_name=_class_name, method_name=_method_name)
223+
self._logger.deprecation('WLSDPLY-22000', USE_ATP, DATABASE_TYPE,
224+
class_name=_class_name, method_name=_method_name)
225225
model_value = self.rcu_properties_map[USE_ATP]
226226
value = alias_utils.convert_to_type('boolean', model_value)
227227
return value == 'true'
@@ -236,8 +236,8 @@ def is_use_ssl(self):
236236
_method_name = 'is_use_ssl'
237237
result = self._get_dictionary_element_value(USE_SSL)
238238
if result is not None:
239-
self._logger.warning('WLSDPLY-22000', USE_ATP, DATABASE_TYPE,
240-
class_name=_class_name, method_name=_method_name)
239+
self._logger.deprecation('WLSDPLY-22000', USE_ATP, DATABASE_TYPE,
240+
class_name=_class_name, method_name=_method_name)
241241
model_value = self.rcu_properties_map[USE_SSL]
242242
value = alias_utils.convert_to_type('boolean', model_value)
243243
return value == 'true'

core/src/main/python/wlsdeploy/util/exit_code.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ class ExitCode(object):
2020
USAGE_ERROR = JExitCode.USAGE_ERROR
2121

2222
HELP = JExitCode.HELP
23+
DEPRECATION = JExitCode.DEPRECATION
2324
RESTART_REQUIRED = JExitCode.RESTART_REQUIRED
2425
CANCEL_CHANGES_IF_RESTART = JExitCode.CANCEL_CHANGES_IF_RESTART

0 commit comments

Comments
 (0)