如何在sidekiq.log日志文件中添加日期?

时间:2017-06-20 15:03:39

标签: ruby-on-rails date logging ruby-on-rails-5 sidekiq

我在Ubuntu Linux上使用Rails 5.0和sidekiq。我开始像这样的伙伴

library(car)
test_data <- mtcars %>% mutate(factored_variable = as.factor(carb))

model_1 <- aov(drat ~ factored_variable , data = test_data)
Anova(model_1, type = "III")

    # Anova Table (Type III tests)
    # 
    # Response: drat
    # Sum Sq Df  F value                Pr(>F)    
    # (Intercept)       94.870  1 313.3656 0.0000000000000005038 ***
    #   factored_variable  0.991  5   0.6546                0.6607    
    # Residuals          7.871 26                                   
    # ---
    #   Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

model_2 <- aov(drat ~ factored_variable - 1, data = test_data)
Anova(model_2, type = "III")

    # Anova Table (Type III tests)
    # 
    # Response: drat
    # Sum Sq Df F value                Pr(>F)    
    # factored_variable 414.92  6  228.42 < 0.00000000000000022 ***
    #   Residuals           7.87 26                                  
    # ---
    #   Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

并在我的config / initializers / sidekiq.rb文件中有这个

cd $APP_ROOT && bundle exec sidekiq -d -P $SIDEKIQ_PID -L $APP_ROOT/log/sidekiq.log -c 1 -e $ENV

我注意到在我的log / sideiiq.log文件中,我的Rails代码中的“puts”输出语句按原样出现,我想在它们前面显示一个日期。如何更改配置,以便在sidekiq日志文件中的每个输出行前面显示日期?

1 个答案:

答案 0 :(得分:1)

Sidekiq工作人员有几个选择:

def perform(args)
  logger.info "My message"
  Sidekiq.logger.info "Another"
  Rails.logger.info "Third!"
end