Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f914454f
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f914454f
编写于
12月 21, 2012
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ActiveSupport::Logger#silence that works the same as the old Logger#silence extension
上级
e0176bf7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
20 deletion
+45
-20
activesupport/CHANGELOG.md
activesupport/CHANGELOG.md
+4
-0
activesupport/lib/active_support/core_ext/logger.rb
activesupport/lib/active_support/core_ext/logger.rb
+3
-20
activesupport/lib/active_support/logger.rb
activesupport/lib/active_support/logger.rb
+4
-0
activesupport/lib/active_support/logger_silence.rb
activesupport/lib/active_support/logger_silence.rb
+24
-0
activesupport/test/logger_test.rb
activesupport/test/logger_test.rb
+10
-0
未找到文件。
activesupport/CHANGELOG.md
浏览文件 @
f914454f
## Rails 4.0.0 (unreleased) ##
*
Add ActiveSupport::Logger#silence that works the same as the old Logger#silence extension.
*DHH*
*
Remove surrogate unicode character encoding from
`ActiveSupport::JSON.encode`
The encoding scheme was broken for unicode characters outside the basic multilingual plane;
since json is assumed to be
`UTF-8`
, and we already force the encoding to
`UTF-8`
,
...
...
activesupport/lib/active_support/core_ext/logger.rb
浏览文件 @
f914454f
require
'active_support/core_ext/class/attribute_accessors'
require
'active_support/deprecation'
require
'active_support/logger_silence'
ActiveSupport
::
Deprecation
.
warn
'this file is deprecated and will be removed'
...
...
@@ -31,27 +32,9 @@ def around_#{level}(before_message, after_message) # def around_debug(before_me
#
# logger.datetime_format = "%Y-%m-%d"
#
# Note: This logger is deprecated in favor of ActiveSupport::Logger
# Note: This logger is deprecated in favor of ActiveSupport::
Buffered
Logger
class
Logger
##
# :singleton-method:
# Set to false to disable the silencer
cattr_accessor
:silencer
self
.
silencer
=
true
# Silences the logger for the duration of the block.
def
silence
(
temporary_level
=
Logger
::
ERROR
)
if
silencer
begin
old_logger_level
,
self
.
level
=
level
,
temporary_level
yield
self
ensure
self
.
level
=
old_logger_level
end
else
yield
self
end
end
include
LoggerSilence
alias
:old_datetime_format
=
:datetime_format
=
# Logging date-time format (string passed to +strftime+). Ignored if the formatter
...
...
activesupport/lib/active_support/logger.rb
浏览文件 @
f914454f
require
'active_support/core_ext/class/attribute_accessors'
require
'active_support/logger_silence'
require
'logger'
module
ActiveSupport
class
Logger
<
::
Logger
include
LoggerSilence
# Broadcasts logs to multiple loggers.
def
self
.
broadcast
(
logger
)
# :nodoc:
Module
.
new
do
...
...
activesupport/lib/active_support/logger_silence.rb
0 → 100644
浏览文件 @
f914454f
require
'active_support/concern'
module
LoggerSilence
extend
ActiveSupport
::
Concern
included
do
cattr_accessor
:silencer
self
.
silencer
=
true
end
# Silences the logger for the duration of the block.
def
silence
(
temporary_level
=
Logger
::
ERROR
)
if
silencer
begin
old_logger_level
,
self
.
level
=
level
,
temporary_level
yield
self
ensure
self
.
level
=
old_logger_level
end
else
yield
self
end
end
end
\ No newline at end of file
activesupport/test/logger_test.rb
浏览文件 @
f914454f
...
...
@@ -120,4 +120,14 @@ def test_buffer_multibyte
byte_string
.
force_encoding
(
"ASCII-8BIT"
)
assert
byte_string
.
include?
(
BYTE_STRING
)
end
def
test_silencing_everything_but_errors
@logger
.
silence
do
@logger
.
debug
"NOT THERE"
@logger
.
error
"THIS IS HERE"
end
assert
!
@output
.
string
.
include?
(
"NOT THERE"
)
assert
@output
.
string
.
include?
(
"THIS IS HERE"
)
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录