How to format ruby logger?

前端 未结 2 1772
忘掉有多难
忘掉有多难 2021-01-31 08:32

How do you format the ruby logger?

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-31 09:14

    logger = Logger.new('nice.log')
    
    logger.formatter = proc do |severity, datetime, progname, msg|
       "NICE: #{msg}\n"
    end
    
    logger.info("I like cheese.")
    
    # nice.log:
    NICE: I like cheese.
    

提交回复
热议问题