5703b-CentralLoggerFallback-default-root-level.diff
src/com/goldencode/p2j/net/RemoteObject.java 2023-05-16 07:49:31 +0000 | ||
---|---|---|
1335 | 1335 |
*/ |
1336 | 1336 |
private static void logExport(String group, String name) |
1337 | 1337 |
{ |
1338 |
if (LOG.isLoggable(Level.FINER) || LOG.isLoggable(Level.FINEST))
|
|
1338 |
if (LOG.isLoggable(Level.FINER)) |
|
1339 | 1339 |
{ |
1340 | 1340 |
LOG.finer("exported " + group + ':' + name); |
1341 | 1341 |
} |
src/com/goldencode/p2j/util/logging/CentralLogger.java 2023-05-16 08:09:47 +0000 | ||
---|---|---|
130 | 130 |
/** The default name for client log files. Used when server-side logging enabled. */ |
131 | 131 |
static final String DEFAULT_LOG_FILE_NAME = |
132 | 132 |
"fwd_%m_" + SORTABLE_DATETIME_FORMAT + "_%uos_%pid_%uf_%as_%g.log"; |
133 |
|
|
134 |
/** The default root logger level for server processes. */ |
|
135 |
static final Level DEFAULT_ROOT_LEVEL = Level.INFO; |
|
133 | 136 | |
134 | 137 |
/** |
135 | 138 |
* The mode of logger operation. There is one more temporary mode designed for ClassLoaders, not included |
src/com/goldencode/p2j/util/logging/CentralLoggerClientStandalone.java 2023-05-16 08:09:47 +0000 | ||
---|---|---|
79 | 79 |
{ |
80 | 80 |
/** The one and only log handler, responsible for writing all logs to files. */ |
81 | 81 |
private static volatile FileHandler fileHandler; |
82 |
|
|
82 | ||
83 | 83 |
/** |
84 | 84 |
* Package-private constructor for CentralLoggerClientStandalone. |
85 | 85 |
* |
src/com/goldencode/p2j/util/logging/CentralLoggerFallback.java 2023-05-16 08:17:49 +0000 | ||
---|---|---|
71 | 71 |
{ |
72 | 72 |
/** The formatter for logs. */ |
73 | 73 |
private static final Formatter LOG_FORMATTER = new SimpleLogFormatter(); |
74 | ||
75 |
/** The root logger's level. */ |
|
76 |
private static Level rootLevel = DEFAULT_ROOT_LEVEL; |
|
74 | 77 |
|
75 | 78 |
/** |
76 | 79 |
* Package-private constructor for CentralLoggerFallback. |
... | ... | |
86 | 89 |
{ |
87 | 90 |
super(loggerName, checkParentLevels, excludeSMContext); |
88 | 91 |
} |
92 | ||
93 |
/** |
|
94 |
* Sets the root logger's level. Expected to be the first statement in the entry class main method. |
|
95 |
* |
|
96 |
* @param level |
|
97 |
* The new root logger's level. |
|
98 |
*/ |
|
99 |
public static void setRootLevel(Level level) |
|
100 |
{ |
|
101 |
rootLevel = level; |
|
102 |
} |
|
89 | 103 |
|
90 | 104 |
/** |
91 | 105 |
* Publishes a log record by printing it to System.out. Log records with level WARNING and ERROR are |
... | ... | |
97 | 111 |
@Override |
98 | 112 |
protected void publish(LogRecord logRecord) |
99 | 113 |
{ |
114 |
if (logRecord.getLevel().intValue() < rootLevel.intValue()) |
|
115 |
{ |
|
116 |
return; |
|
117 |
} |
|
100 | 118 |
if (logRecord.getLevel().intValue() >= Level.WARNING.intValue()) |
101 | 119 |
{ |
102 | 120 |
System.err.print(LOG_FORMATTER.format(logRecord)); |
src/com/goldencode/p2j/util/logging/CentralLoggerServer.java 2023-05-16 08:09:47 +0000 | ||
---|---|---|
93 | 93 |
/** Counter for unique name for the spawner logger Thread. */ |
94 | 94 |
private static final AtomicInteger SPAWNER_THREAD_COUNTER = new AtomicInteger(1); |
95 | 95 | |
96 |
/** The default root logger level for server processes. */ |
|
97 |
private static final Level DEFAULT_ROOT_LEVEL = Level.INFO; |
|
98 | ||
99 | 96 |
/** The default logger level for spawner processes. */ |
100 | 97 |
private static final Level DEFAULT_SPAWNER_LEVEL = Level.WARNING; |
101 | 98 | |
... | ... | |
165 | 162 |
} |
166 | 163 |
catch (Throwable t) |
167 | 164 |
{ |
168 |
LOG.severe("Server process id can't be determined at this time, which will lead to a corrupt" + |
|
169 |
" log file name for the server process. The native library `p2j` loading method " + |
|
170 |
"is likely the cause of the issue.", t); |
|
165 |
LOG.warning("Server process id can't be determined at this time, which will lead to a " + |
|
166 |
"corrupt log file name for the server process. The native library `p2j` " + |
|
167 |
"loading method is likely the cause of the issue."); |
|
168 |
LOG.log(Level.FINE, "", t); |
|
171 | 169 |
return 0L; |
172 | 170 |
} |
173 | 171 |
}; |