source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/kubeadm/kubelet_config.rb | Ruby | apache-2.0 | 307 | master | 1,727 | # frozen_string_literal: true
module Pharos
module Kubeadm
class KubeletConfig
# @param config [Pharos::Config] cluster config
# @param host [Pharos::Configuration::Host] master host-specific config
def initialize(config, host)
@config = config
@host = host
end
# @r... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/kubeadm/init_config.rb | Ruby | apache-2.0 | 307 | master | 1,282 | # frozen_string_literal: true
module Pharos
module Kubeadm
class InitConfig
# @param config [Pharos::Config] cluster config
# @param host [Pharos::Configuration::Host] master host-specific config
def initialize(config, host)
@config = config
@host = host
end
# @retu... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/kubeadm/config_generator.rb | Ruby | apache-2.0 | 307 | master | 2,922 | # frozen_string_literal: true
require_relative 'init_config'
require_relative 'cluster_config'
require_relative 'kubeproxy_config'
require_relative 'kubelet_config'
module Pharos
module Kubeadm
class ConfigGenerator
PHAROS_DIR = Pharos::Kubeadm::PHAROS_DIR
# @return [InitConfig]
attr_reader :... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/kubeadm/cluster_config.rb | Ruby | apache-2.0 | 307 | master | 11,469 | # frozen_string_literal: true
module Pharos
module Kubeadm
class ClusterConfig
PHAROS_DIR = Pharos::Kubeadm::PHAROS_DIR
CA_FILE = '/etc/kubernetes/pki/ca.crt'
AUTHENTICATION_TOKEN_WEBHOOK_CONFIG_DIR = '/etc/kubernetes/authentication'
OIDC_CONFIG_DIR = '/etc/kubernetes/authentication'
... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/pod_security_policy.rb | Ruby | apache-2.0 | 307 | master | 241 | # frozen_string_literal: true
module Pharos
module Configuration
class PodSecurityPolicy < Pharos::Configuration::Struct
attribute :default_policy, Pharos::Types::Strict::String.default('00-pharos-privileged')
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/route.rb | Ruby | apache-2.0 | 307 | master | 1,478 | # frozen_string_literal: true
require 'ipaddr'
module Pharos
module Configuration
class Route < Pharos::Configuration::Struct
ROUTE_REGEXP = %r(^((?<type>\S+)\s+)?(?<prefix>default|[0-9./]+)(\s+via (?<via>\S+))?(\s+dev (?<dev>\S+))?(\s+proto (?<proto>\S+))?(\s+(?<options>.+))?$).freeze
# @param lin... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/kubelet.rb | Ruby | apache-2.0 | 307 | master | 597 | # frozen_string_literal: true
module Pharos
module Configuration
class Kubelet < Pharos::Configuration::Struct
attribute :read_only_port, Pharos::Types::Bool.default(false)
attribute :feature_gates, Pharos::Types::Strict::Hash
attribute :extra_args, Pharos::Types::Strict::Array.of(Pharos::Types... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/audit.rb | Ruby | apache-2.0 | 307 | master | 316 | # frozen_string_literal: true
require_relative "file_audit"
require_relative "webhook_audit"
module Pharos
module Configuration
class Audit < Pharos::Configuration::Struct
attribute :webhook, Pharos::Configuration::WebhookAudit
attribute :file, Pharos::Configuration::FileAudit
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/kube_proxy.rb | Ruby | apache-2.0 | 307 | master | 259 | # frozen_string_literal: true
module Pharos
module Configuration
class KubeProxy < Pharos::Configuration::Struct
attribute :mode, Pharos::Types::String.default('iptables')
attribute :conntrack, Pharos::Types::Strict::Hash
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/etcd.rb | Ruby | apache-2.0 | 307 | master | 407 | # frozen_string_literal: true
module Pharos
module Configuration
class Etcd < Pharos::Configuration::Struct
attribute :endpoints, Pharos::Types::Array.of(Pharos::Types::String)
attribute :version, Pharos::Types::String
attribute :certificate, Pharos::Types::String
attribute :key, Pharos::... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/taint.rb | Ruby | apache-2.0 | 307 | master | 271 | # frozen_string_literal: true
module Pharos
module Configuration
class Taint < Pharos::Configuration::Struct
attribute :key, Pharos::Types::String
attribute :value, Pharos::Types::String
attribute :effect, Pharos::Types::String
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/host.rb | Ruby | apache-2.0 | 307 | master | 5,611 | # frozen_string_literal: true
require_relative 'os_release'
require_relative 'cpu_arch'
require_relative 'bastion'
require_relative '../transport'
require_relative 'repository'
require 'ipaddr'
require 'resolv'
module Pharos
module Configuration
class Host < Pharos::Configuration::Struct
attribute :addre... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/control_plane.rb | Ruby | apache-2.0 | 307 | master | 264 | # frozen_string_literal: true
module Pharos
module Configuration
class ControlPlane < Pharos::Configuration::Struct
attribute :use_proxy, Pharos::Types::Bool.default(false)
attribute :feature_gates, Pharos::Types::Strict::Hash
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/container_runtime.rb | Ruby | apache-2.0 | 307 | master | 225 | # frozen_string_literal: true
module Pharos
module Configuration
class ContainerRuntime < Pharos::Configuration::Struct
attribute :insecure_registries, Pharos::Types::Array.default(proc { [] })
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/network.rb | Ruby | apache-2.0 | 307 | master | 3,930 | # frozen_string_literal: true
require 'ipaddr'
module Pharos
module Configuration
class Network < Pharos::Configuration::Struct
CLUSTER_DNS = '169.254.20.10'
class Weave < Pharos::Configuration::Struct
attribute :trusted_subnets, Pharos::Types::Array.of(Pharos::Types::String)
attrib... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/authentication.rb | Ruby | apache-2.0 | 307 | master | 320 | # frozen_string_literal: true
require_relative 'token_webhook'
require_relative 'oidc'
module Pharos
module Configuration
class Authentication < Pharos::Configuration::Struct
attribute :token_webhook, Pharos::Configuration::TokenWebhook
attribute :oidc, Pharos::Configuration::OIDC
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/cpu_arch.rb | Ruby | apache-2.0 | 307 | master | 526 | # frozen_string_literal: true
module Pharos
module Configuration
class CpuArch < Pharos::Configuration::Struct
SUPPORTED_IDS = %w(
amd64 x86_64
arm64 aarch64
).freeze
attribute :id, Pharos::Types::Strict::String
# @return [Boolean]
def supported?
SUPPORTED_... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/bastion.rb | Ruby | apache-2.0 | 307 | master | 732 | # frozen_string_literal: true
module Pharos
module Configuration
class Bastion < Pharos::Configuration::Struct
attribute :address, Pharos::Types::Strict::String
attribute :user, Pharos::Types::Strict::String
attribute :ssh_key_path, Pharos::Types::Strict::String
attribute :ssh_port, Pharo... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/resolv_conf.rb | Ruby | apache-2.0 | 307 | master | 274 | # frozen_string_literal: true
module Pharos
module Configuration
class ResolvConf < Pharos::Configuration::Struct
attribute :nameserver_localhost, Pharos::Types::Strict::Bool
attribute :systemd_resolved_stub, Pharos::Types::Strict::Bool
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/repository.rb | Ruby | apache-2.0 | 307 | master | 281 | # frozen_string_literal: true
module Pharos
module Configuration
class Repository < Pharos::Configuration::Struct
attribute :name, Pharos::Types::String
attribute :contents, Pharos::Types::String
attribute :key_url, Pharos::Types::String
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/file_audit.rb | Ruby | apache-2.0 | 307 | master | 335 | # frozen_string_literal: true
module Pharos
module Configuration
class FileAudit < Pharos::Configuration::Struct
attribute :path, Pharos::Types::String
attribute :max_age, Pharos::Types::Integer
attribute :max_backups, Pharos::Types::Integer
attribute :max_size, Pharos::Types::Integer
... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/token_webhook.rb | Ruby | apache-2.0 | 307 | master | 236 | # frozen_string_literal: true
module Pharos
module Configuration
class TokenWebhook < Pharos::Configuration::Struct
attribute :config, Pharos::Types::Hash
attribute :cache_ttl, Pharos::Types::String
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/admission_plugin.rb | Ruby | apache-2.0 | 307 | master | 249 | # frozen_string_literal: true
module Pharos
module Configuration
class AdmissionPlugin < Pharos::Configuration::Struct
attribute :name, Pharos::Types::String
attribute :enabled, Pharos::Types::Bool.default(true)
end
end
end |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/os_release.rb | Ruby | apache-2.0 | 307 | master | 398 | # frozen_string_literal: true
module Pharos
module Configuration
class OsRelease < Pharos::Configuration::Struct
attribute :id, Pharos::Types::Strict::String
attribute :id_like, Pharos::Types::Strict::String.optional.default(nil)
attribute :name, Pharos::Types::Strict::String.optional.default(n... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/oidc.rb | Ruby | apache-2.0 | 307 | master | 500 | # frozen_string_literal: true
module Pharos
module Configuration
class OIDC < Pharos::Configuration::Struct
attribute :issuer_url, Pharos::Types::String
attribute :client_id, Pharos::Types::String
attribute :username_claim, Pharos::Types::String
attribute :username_prefix, Pharos::Types::... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/cloud.rb | Ruby | apache-2.0 | 307 | master | 1,093 | # frozen_string_literal: true
module Pharos
module Configuration
class Cloud < Pharos::Configuration::Struct
attribute :provider, Pharos::Types::String
attribute :config, Pharos::Types::String
INTREE_PROVIDERS = %w(aws azure cloudstack gce openstack ovirt photon vsphere).freeze
# @retur... |
github | kontena/pharos-cluster | https://github.com/kontena/pharos-cluster | lib/pharos/configuration/struct.rb | Ruby | apache-2.0 | 307 | master | 276 | # frozen_string_literal: true
require 'dry-struct'
module Pharos
module Configuration
class Struct < Dry::Struct
transform_types do |type|
# all attributes are optional and default to nil...
type.meta(omittable: true)
end
end
end
end |
github | girishso/pluck_to_hash | https://github.com/girishso/pluck_to_hash | pluck_to_hash.gemspec | Ruby | mit | 306 | master | 1,295 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'pluck_to_hash/version'
Gem::Specification.new do |spec|
spec.name = "pluck_to_hash"
spec.version = PluckToHash::VERSION
spec.authors = ["Girish S"]
spec.email ... |
github | girishso/pluck_to_hash | https://github.com/girishso/pluck_to_hash | spec/pluck_to_struct_spec.rb | Ruby | mit | 306 | master | 2,775 | require_relative './spec_helper'
require 'values'
describe 'PluckToStruct' do
before { TestModel.delete_all }
context '.pluck_to_struct' do
before do
TestModel.create!(id: 1, test_attribute: "test1")
TestModel.create!(id: 2, test_attribute: "test2")
TestModel.create!(id: 3, test_attribute: "... |
github | girishso/pluck_to_hash | https://github.com/girishso/pluck_to_hash | spec/migrations.rb | Ruby | mit | 306 | master | 655 | require 'active_record'
def run_migrations
# Turns off messaging during spec running of table creation
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :test_models do |t|
t.string :test_attribute
t.string :serialized_attribute
t.integer :price_1
t.i... |
github | girishso/pluck_to_hash | https://github.com/girishso/pluck_to_hash | spec/pluck_to_hash_spec.rb | Ruby | mit | 306 | master | 1,764 | require_relative './spec_helper'
describe 'PluckToHash' do
before { TestModel.delete_all }
include_context 'making sure alias is fine'
describe '.pluck_to_hash' do
include_context 'essentials'
include_context 'when using a different hash type'
end
context 'when serialize attributes used' do
des... |
github | girishso/pluck_to_hash | https://github.com/girishso/pluck_to_hash | spec/spec_helper.rb | Ruby | mit | 306 | master | 257 | require 'active_record'
require_relative '../lib/pluck_to_hash'
require_relative './migrations'
require_relative './support/shared_examples'
ActiveRecord::Base.establish_connection(
"adapter" => "sqlite3",
"database" => ":memory:"
)
run_migrations() |
github | girishso/pluck_to_hash | https://github.com/girishso/pluck_to_hash | spec/postgresql_spec.rb | Ruby | mit | 306 | master | 776 | require 'active_record'
require_relative '../lib/pluck_to_hash'
require_relative './migrations'
require_relative './support/shared_examples'
describe 'PluckToHash with Postgres' do
before(:all) do
ActiveRecord::Base.remove_connection
@db_name = "pluck_to_hash_test"
%x( createdb -E UTF8 -T template0 #{@d... |
github | girishso/pluck_to_hash | https://github.com/girishso/pluck_to_hash | spec/support/shared_examples.rb | Ruby | mit | 306 | master | 3,652 | shared_context 'essentials' do
before do
3.times.each do
test_model = TestModel.create!
2.times do
TestModelChild.create!(test_model_id: test_model.id)
end
end
end
it 'plucks the ids of the objects to a hash correctly' do
TestModel.all.pluck_to_hash(:id).each do |hash|
... |
github | girishso/pluck_to_hash | https://github.com/girishso/pluck_to_hash | lib/pluck_to_hash.rb | Ruby | mit | 306 | master | 1,660 | require_relative "./pluck_to_hash/version"
module PluckToHash
extend ActiveSupport::Concern
module ClassMethods
def pluck_to_hash(*keys)
block_given = block_given?
hash_type = keys[-1].is_a?(Hash) ? keys.pop.fetch(:hash_type,HashWithIndifferentAccess) : HashWithIndifferentAccess
keys, forma... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | Rakefile | Ruby | mit | 306 | main | 2,463 | begin
require "bundler/setup"
rescue LoadError
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end
require "bundler/gem_tasks"
task :verify_release_branch do
unless `git rev-parse --abbrev-ref HEAD`.chomp == "main"
warn "Gem can only be released from the main branch"
exit 1
... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lumberjack.gemspec | Ruby | mit | 306 | main | 1,232 | Gem::Specification.new do |spec|
spec.name = "lumberjack"
spec.version = File.read(File.join(__dir__, "VERSION")).strip
spec.authors = ["Brian Durand"]
spec.email = ["bbdurand@gmail.com"]
spec.summary = "Extension of Ruby’s standard Logger for advanced, structured logging. Includes log entry attributes, cont... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | Gemfile | Ruby | mit | 306 | main | 384 | source "https://rubygems.org"
gemspec
gem "rake"
gem "irb"
gem "rspec", "~> 3.12"
gem "timecop"
gem "standard", require: false, platforms: [:mri]
gem "simplecov", require: false, platforms: [:mri]
gem "yard", require: false, platforms: [:mri]
group :development do
gem "ruby-prof", require: false, platforms: [:mri]... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack.rb | Ruby | mit | 306 | main | 7,968 | # frozen_string_literal: true
require "rbconfig"
require "time"
require "logger"
require "fiber"
require "pathname"
# Lumberjack is a flexible logging framework for Ruby that extends the standard
# Logger functionality with structured logging, context isolation, and advanced
# formatting capabilities.
#
# The main fe... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/tag_formatter.rb | Ruby | mit | 306 | main | 1,155 | # frozen_string_literal: true
module Lumberjack
# TagFormatter has been renamed to {AttributeFormatter} as part of the transition from
# "tags" to "attributes" terminology in Lumberjack 2.0. This class exists solely for
# backward compatibility with the 1.x API and will be removed in a future version.
#
# Al... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/context_logger.rb | Ruby | mit | 306 | main | 22,417 | # frozen_string_literal: true
require_relative "context_locals"
require_relative "io_compatibility"
require_relative "severity"
module Lumberjack
# ContextLogger provides a logging interface with support for contextual attributes,
# level management, and program name scoping. This module is included by Logger
#... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/io_compatibility.rb | Ruby | mit | 306 | main | 5,150 | # frozen_string_literal: true
module Lumberjack
# IOCompatibility provides methods that allow a logger to be used as an IO-like stream.
# This enables loggers to be used anywhere an IO object is expected, such as for
# redirecting standard output/error or integrating with libraries that expect stream objects.
... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter_registry.rb | Ruby | mit | 306 | main | 3,027 | # frozen_string_literal: true
module Lumberjack
# The formatter registry is used for setting up names to represent Formatter classes. It is used
# in the constructor for Lumberjack::Logger and allows passing in a symbol to reference a
# formatter.
#
# Formatters must respond to the +call+ method.
#
# @ex... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device_registry.rb | Ruby | mit | 306 | main | 2,984 | # frozen_string_literal: true
module Lumberjack
# The device registry is used for setting up names to represent Device classes. It is used
# in the constructor for Lumberjack::Logger and allows passing in a symbol to reference a
# device.
#
# Devices must have a constructor that accepts the options hash as i... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/message_attributes.rb | Ruby | mit | 306 | main | 1,111 | # frozen_string_literal: true
module Lumberjack
# This class can be used as the return value from a formatter +call+ method to
# extract additional attributes from an object being logged. This can be useful when there
# using structured logging to include important metadata in the log entry in addition
# to th... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/local_log_template.rb | Ruby | mit | 306 | main | 7,020 | # frozen_string_literal: true
module Lumberjack
# This is a log template designed for local environments. It provides a simple,
# human-readable format that includes key information about log entries while
# omitting extraneous details. The template can be configured to include or
# exclude certain components ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/severity.rb | Ruby | mit | 306 | main | 2,648 | # frozen_string_literal: true
module Lumberjack
# The standard severity levels for logging messages.
module Severity
# Custom severity level for trace messages, lower than DEBUG.
TRACE = -1
DEBUG = Logger::Severity::DEBUG
INFO = Logger::Severity::INFO
WARN = Logger::Severity::WARN
ERROR = ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/log_entry.rb | Ruby | mit | 306 | main | 8,269 | # frozen_string_literal: true
module Lumberjack
# A structured representation of a single log entry containing the message,
# metadata, and contextual information. LogEntry objects are immutable data
# structures that capture all relevant information about a logging event,
# including timing, severity, source ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/template_registry.rb | Ruby | mit | 306 | main | 2,003 | # frozen_string_literal: true
module Lumberjack
class TemplateRegistry
@templates = {}
class << self
# Register a log template class with a symbol.
#
# @param name [Symbol] The name of the template.
# @param template [String, Class, #call] The log template to register.
def add(... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/logger.rb | Ruby | mit | 306 | main | 21,902 | # frozen_string_literal: true
module Lumberjack
# Lumberjack::Logger is a thread-safe, feature-rich logging implementation that extends Ruby's standard
# library Logger class with advanced capabilities for structured logging.
#
# Key features include:
# - Structured logging with attributes (key-value pairs) ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/context_locals.rb | Ruby | mit | 306 | main | 3,194 | # frozen_string_literal: true
module Lumberjack
# Provides isolated fiber or thread local storage for thread-safe data access.
module ContextLocals
# Lightweight structure to hold context-local data.
#
# @api private
class Data
attr_accessor :context, :logging, :cleared
def initialize(... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/tags.rb | Ruby | mit | 306 | main | 1,418 | # frozen_string_literal: true
module Lumberjack
class Tags
class << self
# Transform hash keys to strings. This method exists for optimization and backward compatibility.
# If a hash already has string keys, it will be returned as is.
#
# @param hash [Hash] The hash to transform.
# ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/forked_logger.rb | Ruby | mit | 306 | main | 6,199 | # frozen_string_literal: true
module Lumberjack
# ForkedLogger provides an isolated logging context that forwards all log entries to a parent logger
# while maintaining its own independent configuration (level, progname, attributes).
#
# This class allows you to create specialized logger instances that:
# - ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/attribute_formatter.rb | Ruby | mit | 306 | main | 19,362 | # frozen_string_literal: true
module Lumberjack
# AttributeFormatter provides flexible formatting control for log entry attributes (key-value pairs).
# It allows you to specify different formatting rules for attribute names, object classes, or
# provide a default formatter for all attributes.
#
# The formatt... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/log_entry_matcher.rb | Ruby | mit | 306 | main | 5,648 | # frozen_string_literal: true
module Lumberjack
# A flexible matching utility for testing and filtering log entries based on
# multiple criteria. This class provides pattern-based matching against log
# entry components including message content, severity levels, program names,
# and custom attributes with sup... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/utils.rb | Ruby | mit | 306 | main | 13,724 | # frozen_string_literal: true
require "socket"
module Lumberjack
# Error raised when a deprecated method is called and the deprecation mode is set to :raise.
class DeprecationError < StandardError
end
# Utils provides utility methods and helper functions used throughout the Lumberjack logging framework.
mo... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/tag_context.rb | Ruby | mit | 306 | main | 478 | # frozen_string_literal: true
module Lumberjack
# This class was renamed to Lumberjack::AttributesHelper. This class is provided for
# backward compatibility with the version 1.x API and will eventually be removed.
#
# @deprecated Use Lumberjack::AttributesHelper instead.
class TagContext < AttributesHelper
... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter.rb | Ruby | mit | 306 | main | 14,466 | # frozen_string_literal: true
require_relative "formatter_registry"
module Lumberjack
# Formatter controls the conversion of log entry messages into a loggable format, allowing you
# to log any object type and have the logging system handle the string conversion automatically.
#
# The formatter system works b... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/attributes_helper.rb | Ruby | mit | 306 | main | 3,027 | # frozen_string_literal: true
module Lumberjack
# This class provides an interface for manipulating a attribute hash in a consistent manner.
class AttributesHelper
class << self
# Expand any values in a hash that are Proc's by calling them and replacing
# the value with the result. This allows sett... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device.rb | Ruby | mit | 306 | main | 7,313 | # frozen_string_literal: true
require_relative "device_registry"
module Lumberjack
# Abstract base class defining the interface for logging output devices.
# Devices are responsible for the final output of log entries to various
# destinations such as files, streams, databases, or external services.
#
# Thi... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/template.rb | Ruby | mit | 306 | main | 14,057 | # frozen_string_literal: true
module Lumberjack
# A flexible template system for converting log entries into formatted strings.
# Templates use mustache style placeholders to create customizable log output formats.
#
# The template system supports the following built-in placeholders:
#
# - <code>{{time}}</... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/remap_attribute.rb | Ruby | mit | 306 | main | 908 | # frozen_string_literal: true
module Lumberjack
# This class can be used as a return value from an AttributeFormatter to indicate that the
# value should be remapped to a new attribute name.
#
# @example
# # Transform duration_millis and duration_micros to seconds and move to
# # the duration attribute... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/entry_formatter.rb | Ruby | mit | 306 | main | 16,206 | # frozen_string_literal: true
module Lumberjack
# EntryFormatter provides a unified interface for formatting complete log entries by combining
# message formatting and attribute formatting into a single, coordinated system.
#
# This class serves as the central formatting coordinator in the Lumberjack logging p... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/context.rb | Ruby | mit | 306 | main | 5,911 | # frozen_string_literal: true
module Lumberjack
# Context stores logging settings and attributes that can be scoped to specific code blocks
# or inherited between loggers. It provides a hierarchical system for managing logging state
# including level, progname, default severity, and custom attributes.
#
# Ch... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/inspect_formatter.rb | Ruby | mit | 306 | main | 876 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Format an object by calling +inspect+ on it. This formatter provides
# a debugging-friendly representation of objects, showing their internal
# structure and contents in a readable format.
#
# The InspectFormatter is particularly u... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/strip_formatter.rb | Ruby | mit | 306 | main | 859 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Format an object by calling +to_s+ on it and stripping leading and trailing whitespace.
# This formatter is useful for cleaning up string values that may have unwanted whitespace
# from user input, file processing, or other sources.
#
... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/id_formatter.rb | Ruby | mit | 306 | main | 1,441 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Format an object that has an id as a hash with keys for class and id. This formatter is useful
# as a default formatter for objects pulled from a data store. By default it will use :id as the
# id attribute.
#
# The formatter creat... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/date_time_formatter.rb | Ruby | mit | 306 | main | 1,341 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Format a Date, Time, or DateTime object. If you don't specify a format in the constructor, it will use
# the ISO-8601 format with microsecond precision. This formatter provides consistent date/time representation
# across your application ... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/round_formatter.rb | Ruby | mit | 306 | main | 1,118 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Round numeric values to a set number of decimal places. This is useful when logging
# floating point numbers to reduce noise and rounding errors in the logs.
#
# The formatter only affects numeric values, leaving other object types unc... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/object_formatter.rb | Ruby | mit | 306 | main | 821 | # frozen_string_literal: true
module Lumberjack
class Formatter
# No-op formatter that returns the object unchanged. This formatter is useful
# as a default or fallback formatter when you want to preserve the original
# object without any transformation.
#
# The ObjectFormatter is commonly used i... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/multiply_formatter.rb | Ruby | mit | 306 | main | 1,335 | # frozen_string_literal: true
module Lumberjack
class Formatter
# This formatter can be used to multiply a numeric value by a specified multiplier and
# optionally round to a specified number of decimal places.
#
# This is useful for unit conversions (e.g., converting seconds to milliseconds)
# o... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/truncate_formatter.rb | Ruby | mit | 306 | main | 1,192 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Truncate a string object to a specific length. This is useful
# for formatting messages when there is a limit on the number of
# characters that can be logged per message. This formatter should
# only be used when necessary since it is... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/tags_formatter.rb | Ruby | mit | 306 | main | 887 | # frozen_string_literal: true
module Lumberjack
# This formatter is designed to output tags in a specific format.
#
# - Simple values will be formatted as "[value]"
# - Arrays will be formatted as "[value1] [value2] [value3]"
# - Hashes will be formatted as "[key1=value1] [key2=value2]"
# - Hashes in array... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/redact_formatter.rb | Ruby | mit | 306 | main | 1,456 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Log sensitive information in a redacted format showing the first and last
# characters of the value, with the rest replaced by asterisks. The number of
# characters shown is dependent on the length of the value; short values will
# not... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/structured_formatter.rb | Ruby | mit | 306 | main | 2,798 | # frozen_string_literal: true
require "set"
module Lumberjack
class Formatter
# Dereference arrays and hashes and recursively call formatters on each element.
# This formatter provides deep traversal of nested data structures, applying
# formatting to all contained elements while handling circular refer... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/pretty_print_formatter.rb | Ruby | mit | 306 | main | 1,323 | # frozen_string_literal: true
require "pp"
require "stringio"
module Lumberjack
class Formatter
# Format an object with its pretty print method. This formatter provides multi-line,
# indented output that makes complex data structures easier to read and debug.
# It's particularly useful for logging hashe... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/tagged_message.rb | Ruby | mit | 306 | main | 494 | # frozen_string_literal: true
require_relative "../message_attributes"
module Lumberjack
# This is a deprecated alias for Lumberjack::MessageAttributes.
#
# @deprecated Use Lumberjack::MessageAttributes instead.
# @see MessageAttributes
class Formatter::TaggedMessage < MessageAttributes
def initialize(m... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/string_formatter.rb | Ruby | mit | 306 | main | 575 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Format an object by calling +to_s+ on it. This is the simplest formatter
# implementation and is commonly used as a fallback for objects that don't
# have specialized formatters.
class StringFormatter
FormatterRegistry.add(:strin... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/formatter/exception_formatter.rb | Ruby | mit | 306 | main | 1,730 | # frozen_string_literal: true
module Lumberjack
class Formatter
# Format an exception including the backtrace. You can specify an object that
# responds to +call+ as a backtrace cleaner. The exception backtrace will be
# passed to this object and the returned array is what will be logged. You can
# u... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/writer.rb | Ruby | mit | 306 | main | 8,621 | # frozen_string_literal: true
module Lumberjack
# A versatile logging device that writes formatted log entries to IO streams.
# This device serves as the foundation for most output-based logging, converting
# LogEntry objects into formatted strings using configurable templates and
# writing them to any IO-comp... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/log_file.rb | Ruby | mit | 306 | main | 3,376 | # frozen_string_literal: true
module Lumberjack
# A file-based logging device that extends the Writer device with automatic
# log rotation capabilities. This device wraps Ruby's standard Logger::LogDevice
# to provide file size-based and time-based log rotation while maintaining
# compatibility with the Lumber... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/buffer.rb | Ruby | mit | 306 | main | 6,005 | # frozen_string_literal: true
module Lumberjack
# A buffered logging device that wraps another logging device. Entries are buffered in memory
# until the buffer size is reached or the device is flushed.
#
# @example Create a buffered device that flushes every 5 entries
# device = Lumberjack::Device::Buffer... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/logger_wrapper.rb | Ruby | mit | 306 | main | 5,453 | # frozen_string_literal: true
module Lumberjack
# A logging device that forwards log entries to another logger instance.
# This device enables hierarchical logging architectures and broadcasting scenarios
# where log entries need to be distributed to multiple loggers or processed through
# different logging pi... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/multi.rb | Ruby | mit | 306 | main | 4,454 | # frozen_string_literal: true
module Lumberjack
# A multiplexing logging device that broadcasts log entries to multiple target
# devices simultaneously. This device enables sophisticated logging architectures
# where a single log entry needs to be processed by multiple output destinations,
# each potentially w... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/test.rb | Ruby | mit | 306 | main | 15,127 | # frozen_string_literal: true
module Lumberjack
# An in-memory logging device designed specifically for testing and debugging
# scenarios. This device captures log entries in a thread-safe buffer, allowing
# test code to make assertions about logged content, verify logging behavior,
# and inspect log entry det... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/size_rolling_log_file.rb | Ruby | mit | 306 | main | 944 | # frozen_string_literal: true
module Lumberjack
# Deprecated device. Use LogFile instead.
#
# @deprecated Use Lumberjack::Device::LogFile
class Device::SizeRollingLogFile < Device::LogFile
attr_reader :max_size
# Create an new log device to the specified file. The maximum size of the log file is speci... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/null.rb | Ruby | mit | 306 | main | 1,157 | # frozen_string_literal: true
module Lumberjack
# A logging device that discards all output. This device provides a silent
# logging implementation useful for testing environments, performance benchmarks,
# or production scenarios where logging needs to be temporarily disabled without
# changing logger configu... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/device/date_rolling_log_file.rb | Ruby | mit | 306 | main | 776 | # frozen_string_literal: true
require "date"
module Lumberjack
# Deprecated device. Use LogFile instead.
#
# @deprecated Use Lumberjack::Device::LogFile
class Device::DateRollingLogFile < Device::LogFile
def initialize(path, options = {})
Utils.deprecated("Lumberjack::Device::DateRollingLogFile", "L... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/rack/context.rb | Ruby | mit | 306 | main | 3,560 | # frozen_string_literal: true
module Lumberjack
module Rack
# Rack middleware ensures that a global Lumberjack context exists for
# the duration of each HTTP request. This middleware creates an isolated
# logging context that automatically cleans up after the request completes,
# ensuring that reques... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | lib/lumberjack/log_entry_matcher/score.rb | Ruby | mit | 306 | main | 10,288 | # frozen_string_literal: true
# Class responsible for scoring and matching log entries against filters.
# This class provides fuzzy matching capabilities to find the best matching
# log entry when exact matches are not available.
class Lumberjack::LogEntryMatcher::Score
# Minimum score threshold for considering a ma... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack_spec.rb | Ruby | mit | 306 | main | 4,963 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack do
describe "VERSION" do
it "is defined" do
expect(Lumberjack::VERSION).not_to be_nil
end
end
describe "#context" do
it "should create a context with attributes for a block" do
Lumberjack.context do
Lu... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/spec_helper.rb | Ruby | mit | 306 | main | 1,767 | # frozen_string_literal: true
require "logger"
require "stringio"
require "fileutils"
require "timecop"
require "tempfile"
begin
require "simplecov"
SimpleCov.start do
add_filter ["/spec/"]
end
rescue LoadError
end
require_relative "../lib/lumberjack"
Lumberjack.raise_logger_errors = true
Lumberjack.depr... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/io_compatibility_spec.rb | Ruby | mit | 306 | main | 2,026 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::IOCompatibility do
let(:logger) { TestContextLogger.new(Lumberjack::Context.new) }
it "can write to the log" do
logger.write("Hello, world")
expect(logger.entries).to eq([
{
message: "Hello, world",
sever... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter_registry_spec.rb | Ruby | mit | 306 | main | 1,206 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::FormatterRegistry do
after do
Lumberjack::FormatterRegistry.remove(:test)
end
it "can add a formatter as a block" do
expect(Lumberjack::FormatterRegistry.registered?(:test)).to be false
Lumberjack::FormatterRegistry.add(... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/formatter_spec.rb | Ruby | mit | 306 | main | 8,988 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Formatter do
let(:formatter) { Lumberjack::Formatter.default }
describe "optimized formatters for primitive types" do
let(:formatter) { Lumberjack::Formatter.new.add(Object, :inspect) }
it "should have an optimized set of for... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/context_logger_spec.rb | Ruby | mit | 306 | main | 28,462 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::ContextLogger do
let(:logger) { TestContextLogger.new }
let(:logger_with_default_context) { TestContextLogger.new(default_context) }
let(:default_context) { Lumberjack::Context.new }
describe "#level" do
it "can be nil" do
... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/utils_spec.rb | Ruby | mit | 306 | main | 7,865 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::Utils do
describe ".hostname" do
it "returns the hostname in UTF-8 encoding" do
expect(Lumberjack::Utils.hostname).to be_a(String)
expect(Lumberjack::Utils.hostname.encoding).to eq(Encoding::UTF_8)
end
it "caches... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/local_log_template_spec.rb | Ruby | mit | 306 | main | 5,614 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::LocalLogTemplate do
let(:entry) do
Lumberjack::LogEntry.new(Time.now, Logger::INFO, "test message", "myapp", 1234, "foo" => "bar", "baz.bax" => "qux")
end
it "formats log entries with values pertinent to test environments" do
... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/log_entry_matcher_spec.rb | Ruby | mit | 306 | main | 12,354 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::LogEntryMatcher do
describe "#match?" do
let(:entry) { Lumberjack::LogEntry.new(Time.now, Logger::INFO, "Test message", "AppName", Process.pid, attributes) }
let(:attributes) { {} }
describe "severity filter" do
it "ma... |
github | bdurand/lumberjack | https://github.com/bdurand/lumberjack | spec/lumberjack/log_entry_spec.rb | Ruby | mit | 306 | main | 8,294 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Lumberjack::LogEntry do
describe "entry values" do
it "should have a time" do
t = Time.now
entry = Lumberjack::LogEntry.new(t, Logger::INFO, "test", "app", 1500, "foo" => "ABCD")
expect(entry.time).to eq(t)
entry.time = t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.