ProductPromotion
Logo

Ruby

made by https://0x3d.site

GitHub - TwP/logging: A flexible logging library for use in Ruby programs based on the design of Java's log4j library.
A flexible logging library for use in Ruby programs based on the design of Java's log4j library. - TwP/logging
Visit Site

GitHub - TwP/logging: A flexible logging library for use in Ruby programs based on the design of Java's log4j library.

GitHub - TwP/logging: A flexible logging library for use in Ruby programs based on the design of Java's log4j library.

.github/workflows/ruby.yml

Logging

by Tim Pease

Description

Logging is a flexible logging library for use in Ruby programs based on the design of Java's log4j library. It features a hierarchical logging system, custom level names, multiple output destinations per log event, custom formatting, and more.

Installation

gem install logging

Examples

This example configures a logger to output messages in a format similar to the core ruby Logger class. Only log messages that are warnings or higher will be logged.

require 'logging'

logger = Logging.logger(STDOUT)
logger.level = :warn

logger.debug "this debug message will not be output by the logger"
logger.warn "this is your last warning"

In this example, a single logger is created that will append to STDOUT and to a file. Only log messages that are informational or higher will be logged.

require 'logging'

logger = Logging.logger['example_logger']
logger.level = :info

logger.add_appenders \
    Logging.appenders.stdout,
    Logging.appenders.file('example.log')

logger.debug "this debug message will not be output by the logger"
logger.info "just some friendly advice"

The Logging library was created to allow each class in a program to have its own configurable logger. The logging level for a particular class can be changed independently of all other loggers in the system. This example shows the recommended way of accomplishing this.

require 'logging'

Logging.logger['FirstClass'].level = :warn
Logging.logger['SecondClass'].level = :debug

class FirstClass
  def initialize
    @logger = Logging.logger[self]
  end

  def some_method
    @logger.debug "some method was called on #{self.inspect}"
  end
end

class SecondClass
  def initialize
    @logger = Logging.logger[self]
  end

  def another_method
    @logger.debug "another method was called on #{self.inspect}"
  end
end

There are many more examples in the examples folder of the logging package. The recommended reading order is the following:

Extending

The Logging framework is extensible via the little-plugger gem-based plugin system. New appenders, layouts, or filters can be released as ruby gems. When installed locally, the Logging framework will automatically detect these gems as plugins and make them available for use.

The logging-email plugin is a good example to follow. It includes a lib/logging/plugins/email.rb file which is detected by the plugin framework. This file declares a Logging::Plugins::Email.initialize_email method that is called when the plugin is loaded.

The three steps for creating a plugin are:

  • create a new Ruby gem: logging-<name>
  • include a plugin file: lib/logging/plugins/<name>.rb
  • define a plugin initializer: Logging::Plugins::<Name>.initialize_<name>

Development

The Logging source code relies on the Mr Bones project for default rake tasks. You will need to install the Mr Bones gem if you want to build or test the logging gem. Conveniently there is a bootstrap script that you can run to setup your development environment.

script/bootstrap

This will install the Mr Bones gem and the required Ruby gems for development. After this is done you can rake rake -T to see the available rake tasks.

License

The MIT License - see the LICENSE file for the full text.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory