Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
alephant-logger-json
Advanced tools
JSON logging driver for the alephant-logger gem.
Add this line to your application's Gemfile:
gem 'alephant-logger-json'
And then execute:
$ bundle
Or install it yourself as:
$ gem install alephant-logger-json
require "alephant/logger"
require "alephant/logger/json"
json_driver = Alephant::Logger::JSON.new "path/to/logfile.log"
logger = Alephant::Logger.setup json_driver
logger.info({ "some_field" => "some_value", "other_field" => "other_value" })
By default, nested JSON values are flattened to strings. To enable nesting, provided that your log analysis tooling supports that, create Alephant::Logger::JSON
as follows:
Alephant::Logger::JSON.new("path/to/logfile.log", :nesting => true)
The logger will set a key of uuid
to n/a
by default for each log request.
This value can be changed by providing a lambda function that contains the logic to determine this value.
There are two methods available to help you:
Alephant::Logger::JSON.session?
: boolean response checking if @@session
has been setAlephant::Logger::JSON.session
: accepts a lambda function (its return value is internally assigned to @@session
)When using tracing, you'll need to provide a binding context as the first argument to your log level method calls.
This is to resolve issues with lambda's scope availability. See Kernal#binding
for more details.
Example usage:
logger.info(binding, :foo => :bar)
If no binding
is provided then tracing is ignored and the logger falls back to its default value.
Note: you can hide the binding necessity behind an abstraction layer if you prefer
The logger includes an option to define a desired logging level. Only log levels that are equal to or higher than the desired level will be logged.
The logger defaults to the lowest level 0
i.e. :debug
when a desired level is undefined.
Example
# Hierarchical Log levels
# 0 => debug
# 1 => info
# 2 => warn
# 3 => error
# When Default level :debug
json_logger = Alephant::Logger::JSON.new("path/to/logfile.log")
# Log all levels >= 0
json_logger.info "This will log"
# When log level is defined
json_logger = Alephant::Logger::JSON.new("path/to/logfile.log", level: :info)
# log all levels >= 1
json_logger.debug "This will NOT log"
json_logger.info "This will log"
Note: The logger expects the desired level to be defined as a Symbol, String or Integer type.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that alephant-logger-json 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.