
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
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.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.