emoji_logs 0.1.1
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 +7 -0
- data/CHANGELOG.md +17 -0
- data/LICENSE.txt +21 -0
- data/README.md +168 -0
- data/lib/emoji_logger/version.rb +5 -0
- data/lib/emoji_logs/version.rb +5 -0
- data/lib/emoji_logs.rb +72 -0
- metadata +83 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: eb2133bfa2ba9c7980ee60b811a8228160b5b40de82377eb3fa20a8aee0b4c6c
|
|
4
|
+
data.tar.gz: 211042e8557a1771054272223731520160fed36c6faabb9f30b221ff7a333430
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: afd9d2e9372fac301c26159789ac4e60bd8b1fd90b7518549ff2f9f378f06dbe6eb5dd3b2f91ec9eff191856dd82b771e18ccfb2e7a2b318184033ed9fbc9905
|
|
7
|
+
data.tar.gz: 1b5c8ba9785331f5a46339c5eb3d09422bac3c9389f6e348e4a693ef991210e6b906caedad096d3a8f4517f71305dc2e4796f674e7fbcff4b1f9ae1b7490f7b4
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-01-06
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release
|
|
12
|
+
- Basic emoji-based logging with 6 log levels (debug, info, success, warn, error, fatal)
|
|
13
|
+
- Support for tagged logs
|
|
14
|
+
- Block syntax for lazy evaluation
|
|
15
|
+
- Configurable log levels
|
|
16
|
+
- Custom output destinations
|
|
17
|
+
- Zero dependencies
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Your Name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# đ¨ EmojiLogger
|
|
2
|
+
|
|
3
|
+
A tiny Ruby logger that makes logs easier (and more fun) to read by adding expressive emojis.
|
|
4
|
+
|
|
5
|
+
Because logs don't have to be boring.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ⨠Features
|
|
10
|
+
|
|
11
|
+
- Simple, intuitive API
|
|
12
|
+
- Emoji-based log levels
|
|
13
|
+
- Optional tagged logs
|
|
14
|
+
- No dependencies
|
|
15
|
+
- Works anywhere Ruby runs
|
|
16
|
+
|
|
17
|
+
## đĻ Installation
|
|
18
|
+
|
|
19
|
+
Add this line to your application's Gemfile:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
gem 'emoji_logger'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
And then execute:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bundle install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or install it yourself as:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
gem install emoji_logger
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## đ Usage
|
|
38
|
+
|
|
39
|
+
### Basic Logging
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
require 'emoji_logger'
|
|
43
|
+
|
|
44
|
+
logger = EmojiLogger.new
|
|
45
|
+
|
|
46
|
+
logger.debug("Starting application")
|
|
47
|
+
logger.info("Server listening on port 3000")
|
|
48
|
+
logger.success("User authentication successful")
|
|
49
|
+
logger.warn("API rate limit approaching")
|
|
50
|
+
logger.error("Failed to connect to database")
|
|
51
|
+
logger.fatal("System out of memory")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Output:
|
|
55
|
+
```
|
|
56
|
+
đ 2026-01-06 10:30:15 DEBUG: Starting application
|
|
57
|
+
âšī¸ 2026-01-06 10:30:16 INFO: Server listening on port 3000
|
|
58
|
+
â
2026-01-06 10:30:17 SUCCESS: User authentication successful
|
|
59
|
+
â ī¸ 2026-01-06 10:30:18 WARN: API rate limit approaching
|
|
60
|
+
â 2026-01-06 10:30:19 ERROR: Failed to connect to database
|
|
61
|
+
đĨ 2026-01-06 10:30:20 FATAL: System out of memory
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Tagged Logs
|
|
65
|
+
|
|
66
|
+
Add context to your logs with tags:
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
logger.info("Processing payment", tag: "Payment")
|
|
70
|
+
logger.success("Email sent", tag: "Notifications")
|
|
71
|
+
logger.error("Invalid request", tag: "API")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Output:
|
|
75
|
+
```
|
|
76
|
+
âšī¸ 2026-01-06 10:30:15 INFO [Payment]: Processing payment
|
|
77
|
+
â
2026-01-06 10:30:16 SUCCESS [Notifications]: Email sent
|
|
78
|
+
â 2026-01-06 10:30:17 ERROR [API]: Invalid request
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Block Syntax
|
|
82
|
+
|
|
83
|
+
Use blocks for lazy evaluation:
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
logger.debug { "Expensive computation: #{expensive_operation}" }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The block is only evaluated if the log level is enabled.
|
|
90
|
+
|
|
91
|
+
### Log Levels
|
|
92
|
+
|
|
93
|
+
Set the minimum log level:
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
logger = EmojiLogger.new(level: :info)
|
|
97
|
+
|
|
98
|
+
logger.debug("This won't be logged")
|
|
99
|
+
logger.info("This will be logged")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Available levels (in order):
|
|
103
|
+
- `:debug` đ
|
|
104
|
+
- `:info` âšī¸
|
|
105
|
+
- `:success` â
(also available as `logger.ok`)
|
|
106
|
+
- `:warn` â ī¸
|
|
107
|
+
- `:error` â
|
|
108
|
+
- `:fatal` đĨ
|
|
109
|
+
|
|
110
|
+
### Custom Output
|
|
111
|
+
|
|
112
|
+
Log to a file or any IO object:
|
|
113
|
+
|
|
114
|
+
```ruby
|
|
115
|
+
# Log to a file
|
|
116
|
+
File.open("app.log", "a") do |file|
|
|
117
|
+
logger = EmojiLogger.new(file)
|
|
118
|
+
logger.info("Logging to file")
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Log to StringIO (useful for testing)
|
|
122
|
+
require 'stringio'
|
|
123
|
+
output = StringIO.new
|
|
124
|
+
logger = EmojiLogger.new(output)
|
|
125
|
+
logger.info("Test message")
|
|
126
|
+
puts output.string
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## đ¯ Why EmojiLogger?
|
|
130
|
+
|
|
131
|
+
Traditional logs can be hard to scan, especially when debugging or monitoring applications. Emojis provide instant visual cues that make it easier to:
|
|
132
|
+
|
|
133
|
+
- đ Quickly spot errors and warnings in long log files
|
|
134
|
+
- đ¨ Differentiate between log levels at a glance
|
|
135
|
+
- đ Make development more enjoyable
|
|
136
|
+
- đ Stay compatible with all Ruby environments (no external dependencies)
|
|
137
|
+
|
|
138
|
+
## đ§Ē Development
|
|
139
|
+
|
|
140
|
+
After checking out the repo, run:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
bundle install
|
|
144
|
+
rake spec
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
To install this gem onto your local machine:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
rake install
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
To release a new version:
|
|
154
|
+
|
|
155
|
+
1. Update the version number in `lib/emoji_logger/version.rb`
|
|
156
|
+
2. Run `bundle exec rake release` to create a git tag and push to RubyGems
|
|
157
|
+
|
|
158
|
+
## đ¤ Contributing
|
|
159
|
+
|
|
160
|
+
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration.
|
|
161
|
+
|
|
162
|
+
## đ License
|
|
163
|
+
|
|
164
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
165
|
+
|
|
166
|
+
## đ Acknowledgments
|
|
167
|
+
|
|
168
|
+
Inspired by the need for more readable logs and the universal language of emojis.
|
data/lib/emoji_logs.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "emoji_logs/version"
|
|
4
|
+
|
|
5
|
+
class EmojiLogs
|
|
6
|
+
LEVELS = {
|
|
7
|
+
debug: { emoji: "đ", name: "DEBUG" },
|
|
8
|
+
info: { emoji: "âšī¸", name: "INFO" },
|
|
9
|
+
success: { emoji: "â
", name: "SUCCESS" },
|
|
10
|
+
warn: { emoji: "â ī¸", name: "WARN" },
|
|
11
|
+
error: { emoji: "â", name: "ERROR" },
|
|
12
|
+
fatal: { emoji: "đĨ", name: "FATAL" }
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
15
|
+
attr_accessor :level, :output
|
|
16
|
+
|
|
17
|
+
def initialize(output = $stdout, level: :debug)
|
|
18
|
+
@output = output
|
|
19
|
+
@level = level
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Log methods for each level
|
|
23
|
+
def debug(message = nil, tag: nil, &block)
|
|
24
|
+
log(:debug, message, tag: tag, &block)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def info(message = nil, tag: nil, &block)
|
|
28
|
+
log(:info, message, tag: tag, &block)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def success(message = nil, tag: nil, &block)
|
|
32
|
+
log(:success, message, tag: tag, &block)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def warn(message = nil, tag: nil, &block)
|
|
36
|
+
log(:warn, message, tag: tag, &block)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def error(message = nil, tag: nil, &block)
|
|
40
|
+
log(:error, message, tag: tag, &block)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def fatal(message = nil, tag: nil, &block)
|
|
44
|
+
log(:fatal, message, tag: tag, &block)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Alias for success
|
|
48
|
+
def ok(message = nil, tag: nil, &block)
|
|
49
|
+
success(message, tag: tag, &block)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def log(severity, message = nil, tag: nil)
|
|
55
|
+
return if severity_level(severity) < severity_level(@level)
|
|
56
|
+
|
|
57
|
+
message = yield if block_given?
|
|
58
|
+
return unless message
|
|
59
|
+
|
|
60
|
+
level_info = LEVELS[severity]
|
|
61
|
+
timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
|
62
|
+
tag_str = tag ? " [#{tag}]" : ""
|
|
63
|
+
|
|
64
|
+
formatted = "#{level_info[:emoji]} #{timestamp} #{level_info[:name]}#{tag_str}: #{message}\n"
|
|
65
|
+
@output.write(formatted)
|
|
66
|
+
@output.flush if @output.respond_to?(:flush)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def severity_level(level)
|
|
70
|
+
LEVELS.keys.index(level) || 0
|
|
71
|
+
end
|
|
72
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: emoji_logs
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Serhiy Yosypenko
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-01-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '13.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '13.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '3.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '3.0'
|
|
41
|
+
description: EmojiLogs is a simple, zero-dependency Ruby logger that uses emojis to
|
|
42
|
+
make log levels instantly recognizable. Perfect for development, debugging, and
|
|
43
|
+
making logs more enjoyable to read.
|
|
44
|
+
email:
|
|
45
|
+
- serhiy.yosipenko@gmail.com
|
|
46
|
+
executables: []
|
|
47
|
+
extensions: []
|
|
48
|
+
extra_rdoc_files: []
|
|
49
|
+
files:
|
|
50
|
+
- CHANGELOG.md
|
|
51
|
+
- LICENSE.txt
|
|
52
|
+
- README.md
|
|
53
|
+
- lib/emoji_logger/version.rb
|
|
54
|
+
- lib/emoji_logs.rb
|
|
55
|
+
- lib/emoji_logs/version.rb
|
|
56
|
+
homepage: https://github.com/yourusername/emoji_logs
|
|
57
|
+
licenses:
|
|
58
|
+
- MIT
|
|
59
|
+
metadata:
|
|
60
|
+
homepage_uri: https://github.com/yourusername/emoji_logs
|
|
61
|
+
source_code_uri: https://github.com/syosypenko/emoji_logger
|
|
62
|
+
changelog_uri: https://github.com/syosypenko/emoji_logger/blob/main/CHANGELOG.md
|
|
63
|
+
post_install_message:
|
|
64
|
+
rdoc_options: []
|
|
65
|
+
require_paths:
|
|
66
|
+
- lib
|
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: 2.6.0
|
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
requirements: []
|
|
78
|
+
rubygems_version: 3.0.3.1
|
|
79
|
+
signing_key:
|
|
80
|
+
specification_version: 4
|
|
81
|
+
summary: A tiny Ruby logger that makes logs easier (and more fun) to read by adding
|
|
82
|
+
expressive emojis.
|
|
83
|
+
test_files: []
|