tiny_log 1.0.0
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/lib/tiny_log.rb +34 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7775d02acbd568f1139deb0b52e0abbe0e35b1cad644ca690b3c90b18f78b838
|
4
|
+
data.tar.gz: 884a5941287b46bb187db70a0812e2e4ee3a254ca7839479b37892eed90e4d99
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79a8295c22b0755d18884b77d4d8ab437143b4549b8c608ef44b3980ffc4508e07786bb00d97300df4691f8710a1bade3376348d0914e7d1db1f1f1704d2b2a0
|
7
|
+
data.tar.gz: 958dcb44bc4dc6c0d114680868014c51b4e1c7875c24f76d2eaf23526a3aa93bcec7dabee1f25be5060b60b7a8668cd1e5843ad7384aa2c2bcc827d41249b758
|
data/lib/tiny_log.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
# This class provides a simple logging utility with some metadata attached:
|
4
|
+
# - timestamp to the microsecond
|
5
|
+
# - the process ID
|
6
|
+
# - logger level
|
7
|
+
# - the log message
|
8
|
+
#
|
9
|
+
# Ex:
|
10
|
+
# l = Log.new
|
11
|
+
# l.erro('hi there')
|
12
|
+
# l.erro('hi there')
|
13
|
+
# 2022-11-18T01:26:37.086295Z 92967 ERRO hi there
|
14
|
+
# ^timestamp to microsecond ^pid ^lvl ^log message
|
15
|
+
class TinyLog
|
16
|
+
# filename: the I/O stream to send log messages to
|
17
|
+
# if unspecified, will default to $stdout
|
18
|
+
# if specified, attempts to open a file with the specified name to append to
|
19
|
+
def initialize(filename=nil)
|
20
|
+
@io = filename ? File.open(filename, 'a') : $stdout
|
21
|
+
end
|
22
|
+
|
23
|
+
# the clever bit that annotates the log message with a log level and UTC
|
24
|
+
# timestamp
|
25
|
+
def method_missing(prefix, *msgs)
|
26
|
+
msgs.each do |m|
|
27
|
+
m.lines.each do |l|
|
28
|
+
@io.puts "#{Time.now.utc.iso8601(6)} #{Process.pid.to_s.rjust(6)} #{prefix.to_s.upcase} #{l}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tiny_log
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Lunt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: want to log stuff to a file or $stdout with timestamps in UTC, and be
|
14
|
+
able to add a logger level to log lines, and absolutely nothing else? then this
|
15
|
+
library is for you.
|
16
|
+
email: jefflunt@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/tiny_log.rb
|
22
|
+
homepage: https://github.com/jefflunt/tiny_log
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.3.7
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: a tiny logger with almost no features
|
45
|
+
test_files: []
|