Skip to content

Commit

Permalink
Merge pull request #38 from bdurand/actions-standardrb
Browse files Browse the repository at this point in the history
Actions + standardrb
  • Loading branch information
bdurand authored Aug 27, 2020
2 parents 1dc5263 + dfc4b66 commit ab5559a
Show file tree
Hide file tree
Showing 70 changed files with 721 additions and 497 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Dependabot update strategy
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
allow:
# Automatically keep all runtime dependencies updated
- dependency-name: "*"
dependency-type: "production"
versioning-strategy: lockfile-only
62 changes: 62 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Continuous Integration
on:
push:
branches:
- master
- actions-*
tags:
- v*
pull_request:
env:
BUNDLE_CLEAN: "true"
BUNDLE_PATH: vendor/bundle
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3
jobs:
specs:
name: ${{ matrix.job }} ruby-${{ matrix.ruby }} ${{ matrix.appraisal }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [ 2.3, 2.4, 2.5, 2.6, 2.7, "jruby" ]
job: [ rspec ]
include:
- ruby: 2.3
appraisal: activesupport_4
job: rspec
- ruby: 2.5
appraisal: activesupport_5
job: rspec
- ruby: 2.6
appraisal: activesupport
job: rspec
- ruby: 2.6
appraisal: logger
job: rspec
- ruby: 2.7
job: standardrb
steps:
- name: checkout
uses: actions/checkout@v2
- name: set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: remove standardrb
if: matrix.appraisal == 'activesupport_4'
run: sed -i 's/gem "standard"/# gem "standard"/' Gemfile
- name: inject appraisal ${{ matrix.appraisal }}
if: matrix.appraisal && matrix.appraisal != ''
run: | # inject a specific appraisal Gemfile
bundle update
bundle exec appraisal generate
bundle config set gemfile "gemfiles/${{ matrix.appraisal }}.gemfile"
- name: install dependencies
run: bundle install
- name: specs
if: matrix.job == 'rspec'
run: bundle exec rake spec
- name: standardrb
if: matrix.job == 'standardrb'
run: bundle exec standardrb
13 changes: 13 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# I really just have issues with the automatic "semantic blocks"

ruby_version: 2.3

format: progress

ignore:
- '**/*':
- Standard/SemanticBlocks
- Performance/RegexpMatch
- 'spec/**/*':
- Lint/UselessAssignment
- Lint/Void
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.8

* Add `Logger#untag` to remove previously set logging tags from a block.

## 1.2.7

* Allow passing frozen hashes to `Logger.tag`. Tags passed to this method are now duplicated so the logger maintains it's own copy of the hash.
Expand Down
21 changes: 19 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
source 'https://rubygems.org'
gemspec
source "https://rubygems.org"

group :runtime do
gemspec
end

group :development, :test do
gem "rake"
gem "rspec", "~> 3.9"
gem "timecop"
gem "appraisal"

# Lock standard to a particular version, esp. cause it's still 0.x.x according to Semver
gem "standard", "0.5.2", require: false
end

group :doc do
gem "yard"
end
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
![Continuous Integration](https://github.com/bdurand/lumberjack/workflows/Continuous%20Integration/badge.svg)
[![Maintainability](https://api.codeclimate.com/v1/badges/a0abc03721fff9b0cde1/maintainability)](https://codeclimate.com/github/bdurand/lumberjack/maintainability)
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)

# Is It Broken?
# Lumberjack

[![Build Status](https://travis-ci.org/bdurand/lumberjack.svg?branch=master)](https://travis-ci.org/bdurand/lumberjack)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

task :default => :appraisals
task default: :appraisals

desc "run the specs using appraisal"
task :appraisals do
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.7
1.2.8
19 changes: 18 additions & 1 deletion gemfiles/activesupport.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ source "https://rubygems.org"

gem "activesupport", require: "activesupport/all"

gemspec path: "../"
group :runtime do
gemspec path: "../"
end

group :development, :test do
gem "rake"
gem "rspec", "~> 3.9"
gem "timecop"
gem "appraisal"
end

group :standardrb do
gem "standard", "0.5.2", require: false
end

group :doc do
gem "yard"
end
19 changes: 18 additions & 1 deletion gemfiles/activesupport_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ source "https://rubygems.org"

gem "activesupport", "~> 4.0", require: "activesupport/all"

gemspec path: "../"
group :runtime do
gemspec path: "../"
end

group :development, :test do
gem "rake"
gem "rspec", "~> 3.9"
gem "timecop"
gem "appraisal"
end

group :standardrb do
gem "standard", "0.5.2", require: false
end

group :doc do
gem "yard"
end
19 changes: 18 additions & 1 deletion gemfiles/activesupport_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ source "https://rubygems.org"

gem "activesupport", "~> 5.0", require: "activesupport/all"

gemspec path: "../"
group :runtime do
gemspec path: "../"
end

group :development, :test do
gem "rake"
gem "rspec", "~> 3.9"
gem "timecop"
gem "appraisal"
end

group :standardrb do
gem "standard", "0.5.2", require: false
end

group :doc do
gem "yard"
end
19 changes: 18 additions & 1 deletion gemfiles/logger.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ source "https://rubygems.org"

gem "logger"

gemspec path: "../"
group :runtime do
gemspec path: "../"
end

group :development, :test do
gem "rake"
gem "rspec", "~> 3.9"
gem "timecop"
gem "appraisal"
end

group :standardrb do
gem "standard", "0.5.2", require: false
end

group :doc do
gem "yard"
end
64 changes: 34 additions & 30 deletions lib/lumberjack.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
# frozen_string_literals: true

require 'rbconfig'
require 'time'
require 'thread'
require 'securerandom'
require 'logger'
require "rbconfig"
require "time"
require "securerandom"
require "logger"

module Lumberjack
LINE_SEPARATOR = (RbConfig::CONFIG['host_os'].match(/mswin/i) ? "\r\n" : "\n")
LINE_SEPARATOR = (RbConfig::CONFIG["host_os"] =~ /mswin/i ? "\r\n" : "\n")

require_relative "lumberjack/severity.rb"
require_relative "lumberjack/formatter.rb"
require_relative "lumberjack/severity"
require_relative "lumberjack/formatter"

require_relative "lumberjack/context.rb"
require_relative "lumberjack/log_entry.rb"
require_relative "lumberjack/device.rb"
require_relative "lumberjack/logger.rb"
require_relative "lumberjack/tags.rb"
require_relative "lumberjack/tag_formatter.rb"
require_relative "lumberjack/tagged_logger_support.rb"
require_relative "lumberjack/tagged_logging.rb"
require_relative "lumberjack/template.rb"
require_relative "lumberjack/rack.rb"
require_relative "lumberjack/context"
require_relative "lumberjack/log_entry"
require_relative "lumberjack/device"
require_relative "lumberjack/logger"
require_relative "lumberjack/tags"
require_relative "lumberjack/tag_formatter"
require_relative "lumberjack/tagged_logger_support"
require_relative "lumberjack/tagged_logging"
require_relative "lumberjack/template"
require_relative "lumberjack/rack"

class << self
# Define a unit of work within a block. Within the block supplied to this
Expand Down Expand Up @@ -54,20 +53,26 @@ def unit_of_work_id
#
# Otherwise, it will return the current context. If one doesn't exist, it will return a new one
# but that context will not be in any scope.
def context
def context(&block)
current_context = Thread.current[:lumberjack_context]
if block_given?
Thread.current[:lumberjack_context] = Context.new(current_context)
begin
yield
ensure
Thread.current[:lumberjack_context] = current_context
end
if block
use_context(Context.new(current_context), &block)
else
current_context || Context.new
end
end


# Set the context to use within a block.
def use_context(context, &block)
current_context = Thread.current[:lumberjack_context]
begin
Thread.current[:lumberjack_context] = (context || Context.new)
yield
ensure
Thread.current[:lumberjack_context] = current_context
end
end

# Return true if inside a context block.
def context?
!!Thread.current[:lumberjack_context]
Expand All @@ -76,14 +81,13 @@ def context?
# Return the tags from the current context or nil if there are no tags.
def context_tags
context = Thread.current[:lumberjack_context]
context.tags if context
context&.tags
end

# Set tags on the current context
def tag(tags)
context = Thread.current[:lumberjack_context]
context.tag(tags) if context
context&.tag(tags)
end

end
end
Loading

0 comments on commit ab5559a

Please sign in to comment.