
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
by Tim Pease
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.
gem install logging
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:
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:
logging-<name>
lib/logging/plugins/<name>.rb
Logging::Plugins::<Name>.initialize_<name>
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.
The MIT License - see the LICENSE file for the full text.
FAQs
Unknown package
We found that logging demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.