lite_logger 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63889c64a548e885015ab2fdea1c41db4750fdf29760bc264531414a2e445c69
4
- data.tar.gz: 88df472c1fc638c10194a23a5b6382e3e0c425188c75362898afa8f939a86e36
3
+ metadata.gz: 283f90541b2fb3caa1a0bef10bda6668aa060b9c98dbd14e1ccbd1bfe40ec840
4
+ data.tar.gz: 125385af15559093117b87761cbbaa8ab22dd4a9f1783a4b082c0828e4e32003
5
5
  SHA512:
6
- metadata.gz: 77e1b370c88d858e7a447f5a68b27862325a763990f8f9e87ae31eecaa1d13e88168542dc1d3db84334b701c143aca3fb424ce9cf4c595981cc6f655917e19b6
7
- data.tar.gz: 25cfe01d9cf287b225ddce98d74fc70637ece8f89cf37307a36e0166d3d853e10926f85823c56c8cba137e3f4733669d61454e13a91419e3eb2a95bcda252cc9
6
+ metadata.gz: 930654b332fe2068143c05378a81d0f281a2f26d9126e78f0c453b387082c9198bfbde4fdaf40bfd37c8b83ab3a17d5f6ba63bddf1943341fd34402a74d2c124
7
+ data.tar.gz: 3a663dfe21319a5680b952b7a9976cf28cf290d8922cae13ef193ff1f2f457d82db5a9fd581b102267fbbdb890ba238a740736d51d0f859458a32c74456a0013
data/CHANGELOG.md CHANGED
@@ -35,3 +35,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
35
35
  ## [0.1.6] - 2024-07-10
36
36
 
37
37
  - Bug fix: Include the intended fix that was missing on the previous version
38
+
39
+ ## [0.1.7] - 2025-08-19
40
+
41
+ - Small text fix in README.md
42
+ - Remove unused file `all_changes.txt`
43
+
44
+ ## [0.1.8] - 2026-03-29
45
+
46
+ - Add optional custom formatter support for application-specific log output.
47
+ - Create parent directories automatically when logging to a file destination.
48
+ - Move development tools out of runtime dependencies.
data/README.md CHANGED
@@ -39,7 +39,7 @@ require 'lite_logger'
39
39
  class MyClass
40
40
  def initialize
41
41
  # Initialize the logger
42
- @logger = LiteLogger.new
42
+ @logger = LiteLogger::Logger.new
43
43
  end
44
44
 
45
45
  def run
@@ -49,7 +49,7 @@ class MyClass
49
49
  @logger.error('This is an error message')
50
50
  @logger.fatal('This is a fatal message')
51
51
 
52
- # Method logic here
52
+ # [...]
53
53
  end
54
54
  end
55
55
  ```
@@ -76,5 +76,4 @@ Bug reports and pull requests are welcome: <https://github.com/dmferrari/lite_lo
76
76
 
77
77
  ## License
78
78
 
79
- License
80
79
  This little gem is available as open-source under the terms of the MIT License (see the LICENSE file in the project root for details).
@@ -1,15 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'fileutils'
4
+ require 'json'
5
+
3
6
  module LiteLogger
4
7
  class Logger
5
8
  LEVELS = { debug: 0, info: 1, warn: 2, error: 3, fatal: 4 }.freeze
6
9
 
7
- attr_accessor :level, :format, :destination
10
+ attr_accessor :level, :format, :destination, :formatter
8
11
 
9
12
  def initialize
10
13
  @level = :info
11
14
  @format = :plain
12
15
  @destination = $stdout
16
+ @formatter = nil
13
17
  end
14
18
 
15
19
  LEVELS.each_key do |level_name|
@@ -29,6 +33,8 @@ module LiteLogger
29
33
 
30
34
  def format_message(level, message)
31
35
  current_time = Time.now
36
+ return @formatter.call(level, message, current_time) if @formatter
37
+
32
38
  case @format
33
39
  when :json
34
40
  { level: level, message: message, timestamp: current_time }.to_json
@@ -41,7 +47,10 @@ module LiteLogger
41
47
  case @destination
42
48
  when $stdout, $stderr
43
49
  @destination.puts message
50
+ when ->(destination) { destination.respond_to?(:puts) }
51
+ @destination.puts message
44
52
  else
53
+ FileUtils.mkdir_p(File.dirname(@destination))
45
54
  File.open(@destination, 'a') { |file| file.puts message }
46
55
  end
47
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LiteLogger
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lite_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Ferrari
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-07-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -17,7 +16,7 @@ dependencies:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
18
  version: '13.0'
20
- type: :runtime
19
+ type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
@@ -31,7 +30,7 @@ dependencies:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
32
  version: '3.0'
34
- type: :runtime
33
+ type: :development
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
@@ -45,7 +44,7 @@ dependencies:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
46
  version: '1.21'
48
- type: :runtime
47
+ type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
@@ -66,7 +65,6 @@ files:
66
65
  - LICENSE.txt
67
66
  - README.md
68
67
  - Rakefile
69
- - all_changes.txt
70
68
  - config/initializers/lite_logger.rb
71
69
  - lib/lite_logger.rb
72
70
  - lib/lite_logger/logger.rb
@@ -81,7 +79,6 @@ metadata:
81
79
  source_code_uri: https://github.com/dmferrari/lite_logger
82
80
  changelog_uri: https://github.com/dmferrari/lite_logger/blob/main/CHANGELOG.md
83
81
  rubygems_mfa_required: 'true'
84
- post_install_message:
85
82
  rdoc_options: []
86
83
  require_paths:
87
84
  - lib
@@ -96,8 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
93
  - !ruby/object:Gem::Version
97
94
  version: '0'
98
95
  requirements: []
99
- rubygems_version: 3.5.3
100
- signing_key:
96
+ rubygems_version: 3.6.7
101
97
  specification_version: 4
102
98
  summary: A lightweight logging solution for Ruby on Rails applications.
103
99
  test_files: []
data/all_changes.txt DELETED
@@ -1,14 +0,0 @@
1
- # File name: Gemfile
2
- # frozen_string_literal: true
3
-
4
- source 'https://rubygems.org'
5
-
6
- gemspec
7
-
8
- gem 'byebug', '~> 11.1'
9
- gem 'rake', '~> 13.0'
10
- gem 'rspec', '~> 3.0'
11
- gem 'rubocop', '~> 1.21'
12
- gem 'ruby-lsp', '~> 0.16.6'
13
-
14
- # -------------------------