Comments (19)
It appears I was doing it wrong. When I correct the code to the following it works:
require 'syslogger'
config.logger = ActiveSupport::TaggedLogging.new(Syslogger.new("fortress-stats", Syslog::LOG_PID, Syslog::LOG_LOCAL7))
from syslogger.
@cavneb What version of syslogger did you used? The solution you posted doesn't work on Rails 4.2.6. Syslogger version 1.6.4
from syslogger.
@basco-johnkevin are you seeing a specific error or just not seeing entries in the syslog?
from syslogger.
@carsonreinke It is throwing this error:
NoMethodError: undefined method `current_tags' for #<Proc:0x007f3a2a515548>
ruby 2.2.5p319
Rails 4.2.6
Syslogger version 1.6.4
from syslogger.
@basco-johnkevin can you send over how you are configuring the logger for Rails?
from syslogger.
I just came across this issue too. It looks to be an issue in anything above rails 4.2.0.
The issue is with https://github.com/rails/rails/blob/v4.2.9/activejob/lib/active_job/logging.rb#L50 reaching into logger.formatter
for current_tags
but syslogger has this defined as a proc, https://github.com/crohr/syslogger/blob/1.6.4/lib/syslogger.rb#L52
@formatter = proc do |severity, datetime, progname, msg|
msg
end
This feels more like rails mis-behaving, but still curious if syslogger maintainers have any ideas for fixing here first?
@rafaelfranca thoughts from rails-land? Is it expected that all loggers (and their formatters) conform to tagging stuffs? Also, formatter being a proc?
from syslogger.
@jnormore : hello! I think it's fixed on the master branch. can you try with it please?
let me know if it's working. if not I'll reopen the issue.
from syslogger.
If the logger is a tagged logger it is expected their formatters conform with tagging stuff and that is what Rails is expecting since it only try to access current_tags
on the formatter when the logger responds to tagged
https://github.com/rails/rails/blob/v4.2.9/activejob/lib/active_job/logging.rb#L41
from syslogger.
@rafaelfranca thanks for the precisions. From what I see it should be working with the master branch : https://github.com/crohr/syslogger/blob/master/lib/syslogger.rb#L120
from syslogger.
Maybe not? Because Rails will try to access current_tags
in the formatter
and the formatter
is just a proc
in the Syslogger case https://github.com/crohr/syslogger/blob/master/lib/syslogger.rb#L50.
from syslogger.
@rafaelfranca : ok, so I assume this current_tags
method is useless (https://github.com/crohr/syslogger/blob/master/lib/syslogger.rb#L142)? And the formatter should be a class and not a proc?
from syslogger.
But this is weird because on Rails master branch the Formatter doesn't have current_tags
: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/logger.rb#L101
It inherits from https://ruby-doc.org/stdlib-2.3.3/libdoc/logger/rdoc/Logger/Formatter.html which don't have the current_tags
method too.
I may be wrong, but maybe the bug is to call the current_tags
method on the formatter and not on the logger class : https://github.com/rails/rails/blob/v4.2.9/activejob/lib/active_job/logging.rb#L50
from syslogger.
Ok, got it : https://github.com/rails/rails/blob/master/activesupport/lib/active_support/tagged_logging.rb
from syslogger.
@jnormore can you please try with the fix_formatter
branch?
from syslogger.
@jnormore hi there! any news?
from syslogger.
Sorry @n-rodriguez probably not going to get a chance to look into this for another few weeks at least.
from syslogger.
Hi there! Any news?
from syslogger.
Also got bit by this when trying to install Loggly which uses this gem. Any news if this has been patched in master?
Update: just tried with master branch and I still get the following error:
undefined method `current_tags' for #Proc:0x007fddfc815f60
from syslogger.
To have the patch you must use the fix_formatter
branch.
from syslogger.
Related Issues (16)
- Could not log "sql.active_record" event HOT 1
- Support for Rails 3 'tagged' logger HOT 2
- Support for custom formatters HOT 1
- Add support for "notice" level severity for syslog HOT 1
- Output methods ignore the block when the first argument is non-nil HOT 2
- Severity is passed as an array in the call to the formatter HOT 1
- log tags position an availability in the formatter HOT 1
- Document Versioning Scheme?
- cleaning of messages? HOT 3
- Still maintain? HOT 7
- Warnings in Ruby 2.4.0
- Cut a new release HOT 5
- Migrate to Travis.com
- Publish release 1.6.6 on Rubygems
- i only saw the code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from syslogger.