简体   繁体   English

awesome_print显示的信息太多

[英]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 : 我有两个问题:

  • What do things like ←[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.

相关问题 是否有awesome_print(如gem)用于Minitest结果 - Is there awesome_print like gem for Minitest result 如何删除awesome_print上的黑色背景 - How to remove black background on awesome_print awesome_print没有显示关联的对象 - awesome_print not showing associated objects 如何在撬内对awesome_print结果进行分页 - How to paginate awesome_print results inside pry 为什么 awesome_print 没有在我的 Rails 4.2 控制台中打印出格式化的 output? - Why isn't awesome_print printing out formatted output in my Rails 4.2 console? 与pry的awesome_print集成-获取dependency.rb:247:“需要”错误 - awesome_print integration with pry - getting dependencies.rb:247:in `require' error 如何在不使用 ~/.irbrc 文件的情况下让 awesome_print 工作? - How do I get awesome_print to work without using ~/.irbrc file? 如何让 awesome_print 在运行的应用程序中在 pry/ruby-debug 中工作 - How to get awesome_print to work in pry/ruby-debug in running app 有没有一种方法可以将awesome_print gem用于每个项目的rails控制台,而无需添加到Gemfile中 - Is there a way to use awesome_print gem for each project's rails console without adding into Gemfile 在Ruby中插入奇怪的配置代码片段(例如awesome_print的config)的正确位置在哪里? - Where is the correct place to insert odd snippets of configuration code in Ruby such as the config for awesome_print?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM