aga-beacon 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7250e253abc7a17ddbff2aa55de7a9cddec795d355bcb4217679edfad36f2483
4
- data.tar.gz: 07d06bf5c64527bb86726f1f38967429d26c384d562e774ef0884e0d24f29be0
3
+ metadata.gz: '091dfa684983dd036dc7f11dfb3255ef60e68168e454864d16b43f59d1581c02'
4
+ data.tar.gz: a4d145db691b0236e634d80a47b34508d7107b9e0a1bb6fd341cbff08b08cd9e
5
5
  SHA512:
6
- metadata.gz: fda5177aad164dffd34a6e6122b052afb1ebf746eca083fa409dfce12a9e6318c18c0dfb5c0287087eef956575dcf94998778f2f0b97229fc51f3483b3574987
7
- data.tar.gz: 8b87b8d0e24147461ad9e85485c57944514558f387dfec4482c6cab902b4cf1c008b29be59c074ac440d55453070435664747e4c600aefcccf8836a473e77042
6
+ metadata.gz: 934b556de9b6c1d7c01e89c4a0886f559423c3d0094300d8d6901ad3dbad4ceef28789cdc38cce7c43ec7f1d8905c23682f4c9c58a8fd1324cec38d4a1f72a31
7
+ data.tar.gz: 5c4287531b35dc4998501f92146a22dfb588adb38d69b9fe66e9e7601f35d4b7a8027433651f6223f7ed0c36129511a837e4e6d0bab41417e7205c55195cc89f
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # Aga-beacon
2
2
 
3
- Aga-message is a Ruby gem that provides a convenient way to format messages to be sent to customers. It offers a set of utilities and methods to compose and customize messages before sending them to clients through various communication channels.
3
+ Aga-beacon is a Ruby gem that provides a convenient way to handle log files. It allows you to write log messages, read log files, clean up log files, and calculate the size of log files in bytes. With this gem, you can efficiently manage log files and extract valuable information from them.
4
4
 
5
5
 
6
6
  ## Features
7
7
 
8
- - Format personalized messages with dynamic content for individual customers.
9
- - Customize message layout, styling, and formatting.
10
- - Localization and internationalization support for multilingual messaging.
8
+ - Write log messages to a log file, including timestamps and customizable log levels.
9
+ - Read log files and extract log entries based on specific criteria, such as date range or log level.
10
+ - Clean up log files by removing old or unnecessary log entries to optimize file size.
11
+ - Calculate the size of log files in bytes, providing insights into the log file's storage requirements.
11
12
 
12
13
  ## Installation
13
14
 
@@ -24,19 +25,13 @@ If bundler is not being used to manage dependencies, install the gem by executin
24
25
  To use Aga-beacon in your application, require the gem and start making requests. Here's a basic example:
25
26
 
26
27
  ```
27
- ENVIRONMENT=development irb
28
+ irb
28
29
 
29
30
  require 'beacon'
30
31
 
31
- Beacon.configuration
32
-
33
- b = Beacon::Service.new('new')
34
- b.log('Hello') # Output: { status: 200 }
35
- b.read('.log/development_new.log') # Output: 'Hello'
36
- b.clear # Output: 0
37
-
38
- b.log('Hello')
39
- b.size('.log/development_new.log') # Output: 56
32
+ b = Beacon::Service.instance
33
+ b.info('Info') # Output: [2023-07-25T21:10:47.656630 #65059] INFO -- : Info
34
+ b.error('Error') # Output: [2023-07-25T21:11:39.089020 #65059] ERROR -- : Error
40
35
 
41
36
  ```
42
37
 
@@ -1,45 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'fileutils'
3
+ require 'logger'
4
4
 
5
5
  module Beacon
6
6
  class Service
7
- def initialize(service)
8
- @environment = ENV['ENVIRONMENT'] || 'production'
9
- @service = service.to_s
7
+ @@instance = nil
10
8
 
11
- FileUtils.mkdir_p('./log/') unless Dir.exist?('./log/')
12
- @log_file = "./log/#{@environment}_#{@service}.log"
9
+ def self.instance
10
+ @@instance ||= new
13
11
  end
14
12
 
15
- def log(text)
16
- FileUtils.touch(@log_file) unless File.exist?(@log_file)
17
-
18
- File.open(@log_file, 'a') do |file|
19
- file.puts("#{Time.now} [#{@environment.capitalize}] - [#{@service.capitalize}] - #{text.capitalize}")
20
- end
21
-
22
- response
23
- end
24
-
25
- def clear
26
- File.truncate(@log_file, 0) if File.exist?(@log_file)
27
-
28
- response
29
- end
30
-
31
- def read(name)
32
- file_content = ''
33
- File.open(name, 'r') { |file| file_content = file.read } if File.exist?(name)
34
- file_content
13
+ private_class_method :new
14
+
15
+ def initialize
16
+ @log = Logger.new($stdout)
17
+ @log.level = Logger::INFO
35
18
  end
36
19
 
37
- def size(name)
38
- File.exist?(name) ? File.size(name) : 0
20
+ def error(message)
21
+ @log.error(message.capitalize)
39
22
  end
40
23
 
41
- def response
42
- { status: 200}
24
+ def info(message)
25
+ @log.info(message.capitalize)
43
26
  end
44
27
  end
45
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Beacon
4
- VERSION = '0.0.0'
4
+ VERSION = '0.0.1'
5
5
  end
data/lib/beacon.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tzinfo'
4
3
  require_relative './beacon/autoloader'
5
4
 
6
5
  module Beacon
@@ -13,10 +12,6 @@ module Beacon
13
12
  ::Beacon::Base.app_info = value
14
13
  end
15
14
 
16
- def configuration
17
- TZInfo::Timezone.get('Europe/Rome')
18
- end
19
-
20
15
  def ping
21
16
  { status: 200 }
22
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aga-beacon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Baldazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-05 00:00:00.000000000 Z
11
+ date: 2023-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -123,47 +123,47 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: nokogiri
126
+ name: logger
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.15'
131
+ version: 1.5.3
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1.15'
138
+ version: 1.5.3
139
139
  - !ruby/object:Gem::Dependency
140
- name: pry
140
+ name: nokogiri
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0.14'
145
+ version: '1.15'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0.14'
152
+ version: '1.15'
153
153
  - !ruby/object:Gem::Dependency
154
- name: tzinfo
154
+ name: pry
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 2.0.6
159
+ version: '0.14'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 2.0.6
166
+ version: '0.14'
167
167
  description: Beacon Ruby is a lightweight gem for write, read & take size of log files.
168
168
  email:
169
169
  - stefanobaldazzi40@gmail.com
@@ -199,5 +199,5 @@ requirements: []
199
199
  rubygems_version: 3.3.24
200
200
  signing_key:
201
201
  specification_version: 4
202
- summary: aga-beacon0.0.0
202
+ summary: aga-beacon0.0.1
203
203
  test_files: []