Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic logger/log-device and tests #375

Closed
wants to merge 19 commits into from

Conversation

Cawllec
Copy link
Contributor

@Cawllec Cawllec commented Oct 3, 2017

Additions

  • Adds a logger to track events output to a logger to breadcrumbs
  • Logger can be assigned to any interface that uses a Logger, such as ActiveRecord::Base.logger or Mongoid::Loggable.logger
  • Adds an appender for use with the logging library
  • Appender includes trackable LogEvent data including file, line, method

@Cawllec Cawllec added needs discussion Requires internal analysis/discussion needs documentation labels Oct 3, 2017
Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments inline, the approach makes sense overall, though I didn't understand the reasoning for some of the details.

message = progname
end
if severity >= level
@log_device.write(message, progname, Bugsnag::Loggers::SEVERITIES[severity])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to define your own level? What happens if its over Logger::UNKNOWN?

true
end

def reopen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will this be used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the base class it's meant to close the connection to a file or IO object. While we're not hanging onto those objects I thought it'd be appropriate to cease logging in similar circumstances

def initialize(level=Logger::INFO)
@open = true
@log_device = Bugsnag::Loggers::LogDevice.new
super @log_device, level
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of having the device over nil here? The add() method could call Bugsnag.leave_breadcrumb directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, there is no advantage. I'll remove this. For some reason I assumed the logger base class wouldn't be happy being passed nil, but it's quite happy.

require "logger"
require "bugsnag"

module Bugsnag::Loggers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit to the Loggers module? Bugsnag::Logger reads nicer. Is there a clash with our internal logger maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's going to be some shared functionality between the Logger and the Appender classes (Appender coming soon). I've thought about renaming the module 'logging' as it's what the module deals with, but it will contain 'loggers', so not sure about that

@Cawllec
Copy link
Contributor Author

Cawllec commented Oct 4, 2017

Added the appender in with tests, I'll get some examples added, one using Appender in a general purpose way and one using Logger to record breadcrumbs from activeRecord

@Cawllec Cawllec removed the needs discussion Requires internal analysis/discussion label Feb 20, 2018
@Cawllec
Copy link
Contributor Author

Cawllec commented Nov 19, 2018

This is becoming part of a separate project

@Cawllec Cawllec closed this Nov 19, 2018
@imjoehaines imjoehaines deleted the cawllec/appender-breadcrumbs branch June 16, 2021 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants