nanolog 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/nanolog.rb +78 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89865772593a2182d735d2f5dc1315598e32a361
|
4
|
+
data.tar.gz: b64873e844f0d97544577e9f9c5943b75878aea5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b59d3d90e0c8c9ca713ad251b5d693f81e7a9fc3eb128f0e5314656fe2c08980a728c63488114e17227e5cf468711e5b34387549d25b82d7d69eaa797e9b6b3
|
7
|
+
data.tar.gz: 3ac694011ed641fc867ce173639ee639a71d25f15d11b04dec3664a30809fccb82b60eb662e7f10baebdedbcd592eedf2ed02b252091554c193ab72b396ea5e0
|
data/lib/nanolog.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# @author Carter Brainerd
|
2
|
+
module NanoLog
|
3
|
+
class Logger
|
4
|
+
|
5
|
+
@logfile = nil
|
6
|
+
|
7
|
+
# Log message builder strings
|
8
|
+
INFO = ' [INFO] '
|
9
|
+
DEBUG = ' [DEBUG] '
|
10
|
+
FATAL = ' [FATAL] '
|
11
|
+
ERROR = ' [ERROR] '
|
12
|
+
SUCCESS = ' [SUCCESS] '
|
13
|
+
|
14
|
+
#
|
15
|
+
# @param path [String] the path to save the logfile at
|
16
|
+
#
|
17
|
+
def initialize(path)
|
18
|
+
raise NanoLog::NilPathError unless !path.nil?
|
19
|
+
@logfile = File.new(path, 'a')
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Write an `info` message to the log file
|
24
|
+
# @param message [String] the message to log
|
25
|
+
#
|
26
|
+
def info(message='')
|
27
|
+
@logfile.write("#{Time.now}#{INFO}#{message}\n")
|
28
|
+
@logfile.rewind
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Write a `debug` message to the log file
|
33
|
+
# @param message [String] the message to log
|
34
|
+
#
|
35
|
+
def debug(message='')
|
36
|
+
@logfile.write("#{Time.now}#{DEBUG}#{message}\n")
|
37
|
+
@logfile.rewind
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Write a `fatal` message to the log file
|
42
|
+
# @param message [String] the message to log
|
43
|
+
#
|
44
|
+
def fatal(message='')
|
45
|
+
@logfile.write("#{Time.now}#{FATAL}#{message}\n")
|
46
|
+
@logfile.rewind
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Write an `error` message to the log file
|
51
|
+
# @param message [String] the message to log
|
52
|
+
#
|
53
|
+
def error(message='')
|
54
|
+
@logfile.write("#{Time.now}#{ERROR}#{message}\n")
|
55
|
+
@logfile.rewind
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Write a `success` message to the log file
|
60
|
+
# @param message [String] the message to log
|
61
|
+
#
|
62
|
+
def success(message='')
|
63
|
+
@logfile.write("#{Time.now}#{SUCCESS}#{message}\n")
|
64
|
+
@logfile.rewind
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# This error should only be used if the path in #initialize
|
71
|
+
#
|
72
|
+
class NilPathError < StandardError
|
73
|
+
def initialize(msg="A nil log path is not allowed")
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nanolog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carter Brainerd
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: cbawsome77@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/nanolog.rb
|
20
|
+
homepage: http://rubygems.org/gems/nanolog
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.5.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: A small and simple logging gem
|
44
|
+
test_files: []
|