Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f91f21c6
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f91f21c6
编写于
1月 16, 2014
作者:
D
dfuchs
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8029740: Enhance handling of loggers
Reviewed-by: mchung, ahgross
上级
b746c767
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
15 deletion
+34
-15
src/share/classes/java/util/logging/LogManager.java
src/share/classes/java/util/logging/LogManager.java
+7
-7
src/share/classes/java/util/logging/Logger.java
src/share/classes/java/util/logging/Logger.java
+27
-8
未找到文件。
src/share/classes/java/util/logging/LogManager.java
浏览文件 @
f91f21c6
...
...
@@ -548,7 +548,7 @@ public class LogManager {
Logger
result
=
getLogger
(
name
);
if
(
result
==
null
)
{
// only allocate the new logger once
Logger
newLogger
=
new
Logger
(
name
,
resourceBundleName
,
caller
,
this
);
Logger
newLogger
=
new
Logger
(
name
,
resourceBundleName
,
caller
,
this
,
false
);
do
{
if
(
addLogger
(
newLogger
))
{
// We successfully added the new Logger that we
...
...
@@ -595,13 +595,13 @@ public class LogManager {
}
while
(
logger
==
null
);
// LogManager will set the sysLogger's handlers via LogManager.addLogger method.
if
(
logger
!=
sysLogger
&&
sysLogger
.
get
Handlers
().
length
==
0
)
{
if
(
logger
!=
sysLogger
&&
sysLogger
.
accessChecked
Handlers
().
length
==
0
)
{
// if logger already exists but handlers not set
final
Logger
l
=
logger
;
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Void
>()
{
@Override
public
Void
run
()
{
for
(
Handler
hdl
:
l
.
get
Handlers
())
{
for
(
Handler
hdl
:
l
.
accessChecked
Handlers
())
{
sysLogger
.
addHandler
(
hdl
);
}
return
null
;
...
...
@@ -919,7 +919,7 @@ public class LogManager {
Logger
result
=
findLogger
(
name
);
if
(
result
==
null
)
{
// only allocate the new system logger once
Logger
newLogger
=
new
Logger
(
name
,
resourceBundleName
,
null
,
getOwner
());
Logger
newLogger
=
new
Logger
(
name
,
resourceBundleName
,
null
,
getOwner
()
,
true
);
do
{
if
(
addLocalLogger
(
newLogger
))
{
// We successfully added the new Logger that we
...
...
@@ -1637,7 +1637,7 @@ public class LogManager {
// We do not call the protected Logger two args constructor here,
// to avoid calling LogManager.getLogManager() from within the
// RootLogger constructor.
super
(
""
,
null
,
null
,
LogManager
.
this
);
super
(
""
,
null
,
null
,
LogManager
.
this
,
true
);
setLevel
(
defaultLevel
);
}
...
...
@@ -1661,9 +1661,9 @@ public class LogManager {
}
@Override
public
Handler
[]
get
Handlers
()
{
Handler
[]
accessChecked
Handlers
()
{
initializeGlobalHandlers
();
return
super
.
get
Handlers
();
return
super
.
accessChecked
Handlers
();
}
}
...
...
src/share/classes/java/util/logging/Logger.java
浏览文件 @
f91f21c6
...
...
@@ -277,6 +277,7 @@ public class Logger {
private
volatile
Level
levelObject
;
private
volatile
int
levelValue
;
// current effective level value
private
WeakReference
<
ClassLoader
>
callersClassLoaderRef
;
private
final
boolean
isSystemLogger
;
/**
* GLOBAL_LOGGER_NAME is a name for the global logger.
...
...
@@ -370,11 +371,12 @@ public class Logger {
* no corresponding resource can be found.
*/
protected
Logger
(
String
name
,
String
resourceBundleName
)
{
this
(
name
,
resourceBundleName
,
null
,
LogManager
.
getLogManager
());
this
(
name
,
resourceBundleName
,
null
,
LogManager
.
getLogManager
()
,
false
);
}
Logger
(
String
name
,
String
resourceBundleName
,
Class
<?>
caller
,
LogManager
manager
)
{
Logger
(
String
name
,
String
resourceBundleName
,
Class
<?>
caller
,
LogManager
manager
,
boolean
isSystemLogger
)
{
this
.
manager
=
manager
;
this
.
isSystemLogger
=
isSystemLogger
;
setupResourceInfo
(
resourceBundleName
,
caller
);
this
.
name
=
name
;
levelValue
=
Level
.
INFO
.
intValue
();
...
...
@@ -401,6 +403,7 @@ public class Logger {
private
Logger
(
String
name
)
{
// The manager field is not initialized here.
this
.
name
=
name
;
this
.
isSystemLogger
=
true
;
levelValue
=
Level
.
INFO
.
intValue
();
}
...
...
@@ -635,7 +638,7 @@ public class Logger {
// cleanup some Loggers that have been GC'ed
manager
.
drainLoggerRefQueueBounded
();
Logger
result
=
new
Logger
(
null
,
resourceBundleName
,
Reflection
.
getCallerClass
(),
manager
);
Reflection
.
getCallerClass
(),
manager
,
false
);
result
.
anonymous
=
true
;
Logger
root
=
manager
.
getLogger
(
""
);
result
.
doSetParent
(
root
);
...
...
@@ -727,15 +730,23 @@ public class Logger {
Logger
logger
=
this
;
while
(
logger
!=
null
)
{
for
(
Handler
handler
:
logger
.
getHandlers
())
{
final
Handler
[]
loggerHandlers
=
isSystemLogger
?
logger
.
accessCheckedHandlers
()
:
logger
.
getHandlers
();
for
(
Handler
handler
:
loggerHandlers
)
{
handler
.
publish
(
record
);
}
if
(!
logger
.
getUseParentHandlers
())
{
final
boolean
useParentHdls
=
isSystemLogger
?
logger
.
useParentHandlers
:
logger
.
getUseParentHandlers
();
if
(!
useParentHdls
)
{
break
;
}
logger
=
logger
.
getParent
();
logger
=
isSystemLogger
?
logger
.
parent
:
logger
.
getParent
();
}
}
...
...
@@ -1762,6 +1773,12 @@ public class Logger {
* @return an array of all registered Handlers
*/
public
Handler
[]
getHandlers
()
{
return
accessCheckedHandlers
();
}
// This method should ideally be marked final - but unfortunately
// it needs to be overridden by LogManager.RootLogger
Handler
[]
accessCheckedHandlers
()
{
return
handlers
.
toArray
(
emptyHandlers
);
}
...
...
@@ -2150,12 +2167,14 @@ public class Logger {
if
(
trb
.
userBundle
!=
null
)
{
return
trb
;
}
final
String
rbName
=
target
.
getResourceBundleName
();
final
String
rbName
=
isSystemLogger
?
trb
.
resourceBundleName
:
target
.
getResourceBundleName
();
if
(
rbName
!=
null
)
{
return
LoggerBundle
.
get
(
rbName
,
findResourceBundle
(
rbName
,
true
));
}
target
=
target
.
getParent
();
target
=
isSystemLogger
?
target
.
parent
:
target
.
getParent
();
}
return
NO_RESOURCE_BUNDLE
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录