Skip to content

Commit

Permalink
Merge pull request #41 from bdurand/truncate-formatter
Browse files Browse the repository at this point in the history
Add truncate formatter
  • Loading branch information
bdurand committed Jul 19, 2023
2 parents 8daadff + a5fc71c commit 6f909f5
Show file tree
Hide file tree
Showing 38 changed files with 654 additions and 187 deletions.
54 changes: 31 additions & 23 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Continuous Integration

on:
push:
branches:
Expand All @@ -7,64 +8,71 @@ on:
tags:
- v*
pull_request:
branches-ignore:
- actions-*

env:
BUNDLE_CLEAN: "true"
BUNDLE_PATH: vendor/bundle
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3

jobs:
specs:
name: ruby-${{ matrix.ruby }} ${{ matrix.appraisal }}
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- ruby: "ruby"
stanardrb: true
standardrb: true
- ruby: "jruby"
- ruby: "3"
- ruby: "3.2"
- ruby: "3.1"
- ruby: "3.0"
- ruby: "2.7"
- ruby: "2.6"
- ruby: "2.5"
- ruby: "2.4"
- ruby: "2.3"
- ruby: "ruby"
appraisal: activesupport_latest
- ruby: "3.1"
appraisal: activesupport_7
- ruby: "3.0"
appraisal: activesupport_6
- ruby: "2.6"
appraisal: activesupport_5
- ruby: "2.5"
appraisal: activesupport_4
bundler: "1.17.3"
- ruby: "2.5"
appraisal: activesupport_5
- ruby: "2.6"
appraisal: activesupport
- ruby: "2.6"
appraisal: logger
- ruby: "ruby"
appraisal: logger_gem
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby
- uses: actions/checkout@v2
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
ruby-version: "${{ matrix.ruby }}"
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install libsqlite3-dev
- name: Setup bundler
if: matrix.bundler != ''
run: |
gem uninstall bundler --all
gem install bundler --no-document --version ${{ matrix.bundler }}
- name: Remove standardrb
if: matrix.ruby == '2.3'
run: sed -i 's/gem "standard"/# gem "standard"/' Gemfile
- name: Set Appraisal bundle
if: matrix.appraisal != ''
run: |
echo "using gemfile gemfiles/${{ matrix.appraisal }}.gemfile"
bundle config set gemfile "gemfiles/${{ matrix.appraisal }}.gemfile"
- name: Install bundle
- name: Install gems
run: |
bundle update
- name: Run specs
if: matrix.job == 'rspec'
run: bundle exec rake spec
- name: Run standardrb
- name: Run Tests
run: bundle exec rake
- name: standardrb
if: matrix.standardrb == true
run: bundle exec standardrb
run: bundle exec rake standard
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
pkg
tmp
rdoc
*.rbc
.DS_Store
.bundle/
.rspec
.rspec_status
.ruby-version
.yardoc/
.env
.tm_properties
Gemfile.lock
coverage/
gemfiles/*.gemfile.lock
log/*.log
pkg/
rdoc/
doc/
12 changes: 10 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
appraise "logger" do
appraise "logger-gem" do
gem "logger"
end

appraise "activesupport" do
appraise "activesupport-latest" do
gem "activesupport", require: "activesupport/all"
end

appraise "activesupport-7" do
gem "activesupport", "~> 7.0", require: "activesupport/all"
end

appraise "activesupport-6" do
gem "activesupport", "~> 6.0", require: "activesupport/all"
end

appraise "activesupport-5" do
gem "activesupport", "~> 5.0", require: "activesupport/all"
end
Expand Down
169 changes: 111 additions & 58 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,129 +1,182 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.2.9

### Added
- Allow passing in formatters as class names when adding them.
- Allow passing in formatters initialization arguments when adding them.
- Add truncate formatter for capping the length of log messages.

## 1.2.8

* Add `Logger#untagged` to remove previously set logging tags from a block.
* Return result of the block when a block is passed to `Logger#tag`.
### Added
- Add `Logger#untagged` to remove previously set logging tags from a block.
- Return result of the block when a block is passed to `Logger#tag`.

## 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.
### Fixed
- 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.

## 1.2.6

* Fix `Logger#tag` so it only ads to the current block's logger tags instead of the global tags if called inside a `Logger#tag` block.
* Add Logger#remove_tag
### Added
- Add Logger#remove_tag

### Fixed
- Fix `Logger#tag` so it only ads to the current block's logger tags instead of the global tags if called inside a `Logger#tag` block.


## 1.2.5

* Fix logic with recursive reference guard in StructuredFormatter so it only suppresses Enumerable references.
* Add support for bang methods (error!) for setting the log level.
### Added
- Add support for bang methods (error!) for setting the log level.

### Fixed
- Fixed logic with recursive reference guard in StructuredFormatter so it only suppresses Enumerable references.

## 1.2.4

* Enhance `ActiveSupport::TaggedLogging` support so code that Lumberjack loggers can be wrapped with a tagged logger.
### Added
- Enhance `ActiveSupport::TaggedLogging` support so code that Lumberjack loggers can be wrapped with a tagged logger.

## 1.2.3

* Fix structured formatter so no-recursive, duplicate references are allowed.
### Fixed
- Fix structured formatter so no-recursive, duplicate references are allowed.

## 1.2.2

* Prevent infinite loops in the structured formatter where objects have backreferences to each other.
### Fixed
- Prevent infinite loops in the structured formatter where objects have backreferences to each other.

## 1.2.1

* Prevent infinite loops where logging a statement triggers the logger.
### Fixed
- Prevent infinite loops where logging a statement triggers the logger.

## 1.2.0

* Enable compatibility with `ActiveSupport::TaggedLogger` by calling `tagged_logger!` on a logger.
* Add `tag_formatter` to logger to specify formatting of tags for output.
* Allow adding and removing classes by name to formatters.
* Allow adding and removing multiple classes in a single call to a formatter.
* Allow using symbols and strings as log level for silencing a logger.
* Ensure flusher thread gets stopped when logger is closed.
* Add writer for logger device attribute.
* Handle passing an array of devices to a multi device.
* Helper method to get a tag with a specified name.
* Add strip formatter to strip whitespace from strings.
* Support non-alpha numeric characters in template variables.
* Add backtrace cleaner to ExceptionFormatter.
### Added
- Enable compatibility with `ActiveSupport::TaggedLogger` by calling `tagged_logger!` on a logger.
- Add `tag_formatter` to logger to specify formatting of tags for output.
- Allow adding and removing classes by name to formatters.
- Allow adding and removing multiple classes in a single call to a formatter.
- Allow using symbols and strings as log level for silencing a logger.
- Ensure flusher thread gets stopped when logger is closed.
- Add writer for logger device attribute.
- Handle passing an array of devices to a multi device.
- Helper method to get a tag with a specified name.
- Add strip formatter to strip whitespace from strings.
- Support non-alpha numeric characters in template variables.
- Add backtrace cleaner to ExceptionFormatter.

## 1.1.1

* Replace Procs in tag values with the value of calling the Proc in log entries.
### Added
- Replace Procs in tag values with the value of calling the Proc in log entries.

## 1.1.0

* Change `Lumberjack::Logger` to inherit from ::Logger
* Add support for tags on log messages
* Add global tag context for all loggers
* Add per logger tags and tag contexts
* Reimplement unit of work id as a tag on log entries
* Add support for setting datetime format on log devices
* Performance optimizations
* Add Multi device to output to multiple devices
* Add `DateTimeFormatter`, `IdFormatter`, `ObjectFormatter`, and `StructuredFormatter`
* Add rack `Context` middleware for setting thread global context
* End support for ruby versions < 2.3
* Add support for modules in formatters
### Added
- Change `Lumberjack::Logger` to inherit from ::Logger
- Add support for tags on log messages
- Add global tag context for all loggers
- Add per logger tags and tag contexts
- Reimplement unit of work id as a tag on log entries
- Add support for setting datetime format on log devices
- Performance optimizations
- Add Multi device to output to multiple devices
- Add `DateTimeFormatter`, `IdFormatter`, `ObjectFormatter`, and `StructuredFormatter`
- Add rack `Context` middleware for setting thread global context
- Add support for modules in formatters

### Removed
- End support for ruby versions < 2.3

## 1.0.13

* Reduce amount of code executed inside a mutex lock when writing to the logger stream.
* Added `:min_roll_check` option to `Lumberjack::Device::RollingLogFile` to reduce file system checks. Default is now to only check if a file needs to be rolled at most once per second.
* Force immutable strings for Ruby versions that support them.
### Added
- Added `:min_roll_check` option to `Lumberjack::Device::RollingLogFile` to reduce file system checks. Default is now to only check if a file needs to be rolled at most once per second.
- Force immutable strings for Ruby versions that support them.

### Changed
- Reduce amount of code executed inside a mutex lock when writing to the logger stream.

## 1.0.12

* Add support for `ActionDispatch` request id for better Rails compatibility.
### Added
- Add support for `ActionDispatch` request id for better Rails compatibility.

## 1.0.11

* Fix Ruby 2.4 deprecation warning on Fixnum (thanks koic).
* Fix gemspec files to be flat array (thanks e2).
### Fixed
- Fix Ruby 2.4 deprecation warning on Fixnum (thanks koic).
- Fix gemspec files to be flat array (thanks e2).

## 1.0.10

* Expose option to manually roll log files.
* Minor code cleanup.
### Added
- Expose option to manually roll log files.

### Changed
- Minor code cleanup.

## 1.0.9

* Add method so Formatter is compatible with `ActiveSupport` logging extensions.
### Added
- Add method so Formatter is compatible with `ActiveSupport` logging extensions.

## 1.0.8

* Fix another internal variable name conflict with `ActiveSupport` logging extensions.
### Fixed
- Fix another internal variable name conflict with `ActiveSupport` logging extensions.

## 1.0.7

* Fix broken formatter attribute method.
### Fixed
- Fix broken formatter attribute method.

## 1.0.6

* Fix internal variable name conflict with `ActiveSupport` logging extensions.
### Fixed
- Fix internal variable name conflict with `ActiveSupport` logging extensions.

## 1.0.5

* Update docs.
* Remove autoload calls to make thread safe.
* Make compatible with Ruby 2.1.1 Pathname.
* Make compatible with standard library Logger's use of progname as default message.
### Changed
- Update docs.
- Remove autoload calls to make thread safe.
- Make compatible with Ruby 2.1.1 Pathname.
- Make compatible with standard library Logger's use of progname as default message.

## 1.0.4

* Add ability to supply a unit of work id for a block instead of having one generated every time.
### Added
- Add ability to supply a unit of work id for a block instead of having one generated every time.

## 1.0.3

* Change log file output format to binary to avoid encoding warnings.
* Fixed bug in log file rolling that left the file locked.
### Fixed
- Change log file output format to binary to avoid encoding warnings.
- Fixed bug in log file rolling that left the file locked.

## 1.0.2

* Remove deprecation warnings under ruby 1.9.3.
* Add more error checking around file rolling.
### Fixed
- Remove deprecation warnings under ruby 1.9.3.
- Add more error checking around file rolling.

## 1.0.1

* Writes are no longer buffered by default.
### Fixed
- Writes are no longer buffered by default.

## 1.0.0

### Added
- Initial release
Loading

0 comments on commit 6f909f5

Please sign in to comment.