[英]Too much information displayed with awesome_print
I'm using awesome_print
, and when I run a command in which awesome_print is invoked, the following result is returned: 我正在使用awesome_print
,并且在运行其中调用awesome_print的命令时,将返回以下结果:
irb(main):002:0> ap User.find(1)
←[1m←[36mUser Load (0.0ms)←[0m ←[1mSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1←[0m [["id", 1]]
#<User:0x57d9650> {
:id←[0;37m => ←[0m←[1;34m1←[0m,
:name←[0;37m => ←[0m←[0;33m"aa"←[0m,
:email←[0;37m => ←[0m←[0;33m"aa"←[0m,
:created_at←[0;37m => ←[0m←[0;32mTue, 26 May 2015 15:13:51 UTC +00:00←[0m,
:updated_at←[0;37m => ←[0m←[0;32mTue, 26 May 2015 15:13:51 UTC +00:00←[0m
However, I notice information like ←[0;37m
is displayed. 但是,我注意到显示了诸如←[0;37m
类的信息。
I have two questions : 我有两个问题:
←[0;37m
mean? ←[0;37m
是什么意思? How do you delete the above notation in order to print results like: 如何删除上述表示法以便打印结果,例如:
:id => 1, :first_name => "aa", :last_name => "aa" :created_at => Tue, 26 May 2015 15:13:51 UTC +00:00
Thank you in advance! 先感谢您!
The 0;37m
-type content are ANSI color codes - it's possible your current setup isn't rendering them properly. 0;37m
类型的内容是ANSI颜色代码-您当前的设置可能无法正确呈现它们。
You should be able to remove those notations by modifying the default color setting in awesome_print. 您应该可以通过修改awesome_print中的默认颜色设置来删除这些符号。 A file, awesome_print.rb
, can be created in the config/initializers directory. 可以在config / initializers目录中创建文件awesome_print.rb
。
config/initializers/awesome_print.rb: 配置/初始化/ awesome_print.rb:
AwesomePrint.defaults = {
:plain => true # do not use colors
# any further default settings you wish to specify
}
Hope it helps! 希望能帮助到你!
If you are not using colors you might as well not use awesome_print
gem. 如果您不使用颜色,则最好不要使用awesome_print
gem。 There is ruby built in plain text pretty print. 有红宝石内置纯文本漂亮的打印。
require 'pp'
pp User.find(1)
You are probably running this on windows machine, if so check out ANSI color codes for Windows Command Prompt 您可能正在Windows计算机上运行此程序,如果是这样,请查看Windows命令提示符下的ANSI颜色代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.