Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
b7d9d6e2
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,发现更多精彩内容 >>
提交
b7d9d6e2
编写于
3月 15, 2013
作者:
T
Terence Lee
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make new rails apps log to STDOUT
上级
b601399b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
47 addition
and
5 deletion
+47
-5
activesupport/lib/active_support/tagged_logging.rb
activesupport/lib/active_support/tagged_logging.rb
+8
-0
activesupport/test/tagged_logging_test.rb
activesupport/test/tagged_logging_test.rb
+11
-0
railties/CHANGELOG.md
railties/CHANGELOG.md
+4
-0
railties/lib/rails/application/bootstrap.rb
railties/lib/rails/application/bootstrap.rb
+1
-5
railties/lib/rails/generators/rails/app/templates/config/application.rb
...ails/generators/rails/app/templates/config/application.rb
+2
-0
railties/test/application/configuration_test.rb
railties/test/application/configuration_test.rb
+21
-0
未找到文件。
activesupport/lib/active_support/tagged_logging.rb
浏览文件 @
b7d9d6e2
...
...
@@ -54,6 +54,14 @@ def tags_text
end
end
def
self
.
create
(
f
,
formatter
,
level
)
logger
=
ActiveSupport
::
Logger
.
new
f
logger
.
formatter
=
formatter
logger
=
new
(
logger
)
logger
.
level
=
ActiveSupport
::
Logger
.
const_get
(
level
.
to_s
.
upcase
)
logger
end
def
self
.
new
(
logger
)
# Ensure we set a default formatter so we aren't extending nil!
logger
.
formatter
||=
ActiveSupport
::
Logger
::
SimpleFormatter
.
new
...
...
activesupport/test/tagged_logging_test.rb
浏览文件 @
b7d9d6e2
...
...
@@ -22,6 +22,17 @@ def flush(*)
assert
logger
.
formatter
.
respond_to?
(
:tagged
)
end
test
'creates a tagged logger with the appropriate level and formatter'
do
stringio
=
StringIO
.
new
logger
=
ActiveSupport
::
TaggedLogging
.
create
(
stringio
,
ActiveSupport
::
Logger
::
SimpleFormatter
.
new
,
:debug
)
logger
.
debug
(
"foo"
)
assert_not_nil
logger
.
formatter
assert
logger
.
formatter
.
respond_to?
(
:tagged
)
assert_equal
0
,
logger
.
level
assert
stringio
.
string
.
include?
(
"foo"
)
end
test
"tagged once"
do
@logger
.
tagged
(
"BCX"
)
{
@logger
.
info
"Funky time"
}
assert_equal
"[BCX] Funky time
\n
"
,
@output
.
string
...
...
railties/CHANGELOG.md
浏览文件 @
b7d9d6e2
## Rails 4.0.0 (unreleased) ##
*
New rails apps log to STDOUT by default
*Terence Lee*
*
Add support for generate scaffold password:digest
* adds password_digest attribute to the migration
...
...
railties/lib/rails/application/bootstrap.rb
浏览文件 @
b7d9d6e2
...
...
@@ -39,11 +39,7 @@ module Bootstrap
f
.
binmode
f
.
sync
=
config
.
autoflush_log
# if true make sure every write flushes
logger
=
ActiveSupport
::
Logger
.
new
f
logger
.
formatter
=
config
.
log_formatter
logger
=
ActiveSupport
::
TaggedLogging
.
new
(
logger
)
logger
.
level
=
ActiveSupport
::
Logger
.
const_get
(
config
.
log_level
.
to_s
.
upcase
)
logger
logger
=
ActiveSupport
::
TaggedLogging
.
create
(
f
,
config
.
log_formatter
,
config
.
log_level
)
rescue
StandardError
logger
=
ActiveSupport
::
TaggedLogging
.
new
(
ActiveSupport
::
Logger
.
new
(
STDERR
))
logger
.
level
=
ActiveSupport
::
Logger
::
WARN
...
...
railties/lib/rails/generators/rails/app/templates/config/application.rb
浏览文件 @
b7d9d6e2
...
...
@@ -32,5 +32,7 @@ class Application < Rails::Application
# Disable the asset pipeline.
config
.
assets
.
enabled
=
false
<
% end
-
%>
config.logger = ActiveSupport::TaggedLogging.create(STDOUT, config.log_formatter, config.log_level)
end
end
railties/test/application/configuration_test.rb
浏览文件 @
b7d9d6e2
...
...
@@ -670,5 +670,26 @@ def index
end
end
end
test
"set logger to STDOUT by default"
do
stdout
=
capture
(
:stdout
)
do
app
=
build_app
controller
:omg
,
<<-
RUBY
class OmgController < ApplicationController
def index
Rails.logger.info "HI MOM"
render text: "omg"
end
end
RUBY
require
"
#{
app_path
}
/config/environment"
get
"/omg/index"
end
assert
stdout
.
include?
(
"HI MOM"
),
"STDOUT does not include 'HI MOM',
#{
stdout
}
"
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录