Code Monkey home page Code Monkey logo

syslogger's Introduction

Syslogger

GitHub license GitHub release Gem Gem CI

A drop-in replacement for the standard Logger Ruby library, that logs to the syslog instead of a log file. Contrary to the SyslogLogger library, you can specify the facility and the syslog options.

Installation

$ gem install syslogger

Usage

require 'syslogger'

# Will send all messages to the local0 facility, adding the process id in the message
logger = Syslogger.new("app_name", Syslog::LOG_PID, Syslog::LOG_LOCAL0)

# Optionally split messages to the specified number of bytes
logger.max_octets = 480

# Send messages that are at least of the Logger::INFO level
logger.level = Logger::INFO # use Logger levels

logger.debug "will not appear"
logger.info "will appear"
logger.warn "will appear"

Contributions

See https://github.com/crohr/syslogger/contributors.

Copyright

Copyright (c) 2010 Cyril Rohr, INRIA Rennes-Bretagne Atlantique. See LICENSE for details.

syslogger's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

syslogger's Issues

Document Versioning Scheme?

I'm wondering what the versioning scheme is for the syslogger gem, and would be happy to add a PR for the README to define it, but I wanted to clarify first. Is it semantic versioning now, or something else? I noticed 1.6 dropped support for Ruby 1.8.7, which would warrant a major version update with semantic versioning. Will there be breaking changes in future minor version updates or not?

Warnings in Ruby 2.4.0

Getting warnings in Ruby 2.4.0:
./vendor/bundle/ruby/2.4.0/gems/syslogger-1.6.4/lib/syslogger.rb:129: warning: constant ::Fixnum is deprecated

log tags position an availability in the formatter

When using a custom formatter, the log tags are not provided in the message contrary to the tagged logger in rails 3 (4?).

We use a custom formatter implementing call(severity, time, progname, msg).

Using the rails default logger with tagged logging, the msg parameter already contains the tags prepended to the actual message.

When using the Syslogger class, the tags seem to get prepended after the call to the formatter when sending the message to the syslog daemon.

Severity is passed as an array in the call to the formatter

The formatter gets called like this on line 96:

clean(formatter.call([severity], Time.now, progname, communication))

Any reason why the severity is wrapped in an array? The default ruby logger does not use an array here but sends a Severity object which provides a label like "INFO" or "DEBUG" when .to_s is applied.

We are migrating to syslog for all logging in our application and just noted that the call to the formatter is different.

Output methods ignore the block when the first argument is non-nil

This is different from the Logger behavior:

$ irb --noecho
irb(main):001:0> require 'logger'
irb(main):002:0> l = Logger.new(STDOUT)
irb(main):003:0> l.info("foo") { "bar" }
I, [2015-04-05T01:45:37.844138 #11084]  INFO -- foo: bar
irb(main):004:0> l.error("foo") { "bar" }
E, [2015-04-05T01:49:18.446210 #11084] ERROR -- foo: bar

Also see http://ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html#method-i-info, especially the first example.

This feature is used in the wild: https://github.com/lostisland/faraday/blob/master/lib/faraday/response/logger.rb#L22-L23, and this is an example of a third-party code expecting a Logger value, which I can't simply replace with Syslogger.

Could not log "sql.active_record" event

Nice simple gem!

I'm getting these warnings to my logs after enabling this gem in rails 3.0.0.rc project.

Aug 18 10:10:50 app app_rails[17595]: Could not log "sql.active_record" event. NoMethodError: undefined method `debug?' for #Syslogger:0x00000002873000
Aug 18 10:11:20 app app_rails[17595]: last message repeated 51 times

Incompatible with Rails 4.2 active jobs?

Here's my configuration in production.rb:

require 'syslogger'
config.logger = Syslogger.new("fortress-stats", Syslog::LOG_PID, Syslog::LOG_LOCAL7)

When I try to create an async job to run (e.g. MyJob.perform_later('foo', d1, d2)) I get the following error:

NoMethodError: undefined method `current_tags' for #<Proc:0x00000005b6a580>
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activejob-4.2.0/lib/active_job/logging.rb:50:in `logger_tagged_by_active_job?'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activejob-4.2.0/lib/active_job/logging.rb:42:in `tag_logger'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activejob-4.2.0/lib/active_job/logging.rb:13:in `block (2 levels) in <module:Logging>'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:436:in `instance_exec'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:436:in `block in make_lambda'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:337:in `call'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:337:in `block in simple'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `call'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:92:in `_run_callbacks'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:734:in `_run_enqueue_callbacks'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/callbacks.rb:81:in `run_callbacks'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activejob-4.2.0/lib/active_job/enqueuing.rb:67:in `enqueue'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/activejob-4.2.0/lib/active_job/enqueuing.rb:17:in `perform_later'
    from (irb):21
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in `start'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /var/deploy/fortress_stats/web_head/shared/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:8:in `require'
    from bin/rails:8:in `<main>'irb(main):022:0> exit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.