Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3605450
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:07:30+00:00 2026-05-18T21:07:30+00:00

I use tail -f to display the log file when developing my Rails app.

  • 0

I use tail -f to display the log file when developing my Rails app.
It shows the log messages (in color! :), which is great.

But with so much information in the 80-width console, it becomes difficult to track where a certain “set” of log messages started when, say, I clicked on a button to GET a resource.

It would be easier if there was a line number or even a time stamp at the start of each log message/line. This way I could remember that I need to start looking at the log “after line number 2365” or “after 2010/10/10 23:33:23:45”.

Is this possible to do? Is there some Rails internal option for this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:07:31+00:00Added an answer on May 18, 2026 at 9:07 pm

    Thanks @scaney.

    I found a solution here.

    I modified that code to add my own coloring highlights (for development only of course!) and now I can see things like ‘parameters’ in yellow in the console and I’m very pleased now!

    In case someone is interested, here is the code I put at the end of environment.rb.
    Here is my current (dirty) implementation. Will probably fix this up later (maybe make a gem, but for now this serves me fine)

    WARNING

    DIRTY CODE FOLLOWS! Use at your own risk!

    module ActiveSupport
      class BufferedLogger
    
        #define the ANSI escape codes for normal and bright colors
        $my_my_ansi_colors = {
    
          :normal => "\x1B[0m",
    
          :black => "\x1B[30m",
          :red => "\x1B[31m", #red
          :green => "\x1B[32m",
          :yellow => "\x1B[33m",
          :blue => "\x1B[34m",
          :magenta => "\x1B[35m",
          :cyan => "\x1B[36m",
          :white => "\x1B[37m",
    
          :bred => "\x1B[1m\x1B[31m", #bright red
          :bgreen => "\x1B[1m\x1B[32m",
          :byellow => "\x1B[1m\x1B[33m",
          :bblue => "\x1B[1m\x1B[34m",
          :bmagenta => "\x1B[1m\x1B[35m",
          :bcyan => "\x1B[1m\x1B[36m",
          :bwhite => "\x1B[1m\x1B[37m",
        }
    
        #take a string and using the keys in the hash, replace the keys in the 
        #string but surround the keys with ANSI color codes
        #No idea how to retain the case of the key!(TODO someday)
        def my_highlight msgx,hash
          return msgx if msgx.blank?
          return msgx if hash.empty?
          hash.each_pair do |k,v|
            if not k.nil?
              msgx.gsub! Regexp.new(k, Regexp::IGNORECASE), $my_my_ansi_colors[:normal]+$my_my_ansi_colors[v]+k.upcase+$my_my_ansi_colors[:normal]
            end
          end
          msgx
        end
    
    
        def add(severity, message = nil, progname = nil, &block)
          return if @level > severity
    
          message = (message || (block && block.call) || progname).to_s
    
          #INSERT BEGINS
          if not $myownglobalnumbercounter.nil?
            $myownglobalnumbercounter += 1
          else
            $myownglobalnumbercounter = 1
          end
    
          level = {
            0 => "DEBUG",
            1 => "INFO",
            2 => "WARN",
            3 => "ERROR",
            4 => "FATAL"
          }[severity] || "U"
    
          message = "\x1B[0m[%d %s] : %s" % [$myownglobalnumbercounter,level,message]
          message = my_highlight message, {
            "debug" => :white,
            "error" => :bred,
            "info" => :bwhite,
            "warning" => :byellow,
            "warn" => :byellow ,
            "parameters" => :byellow,
            "#" => :bgreen,
            "ms " => :bmagenta,
            "GET " => :bmagenta,
            "PUT " => :bmagenta,
            "POST " => :bmagenta,
            "DELETE " => :bmagenta
            }
          #INSERT ENDS
    
          message = "#{message}\n" unless message[-1] == ?\n
          buffer << message
          auto_flush
          message
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.