nanolog 0.1.1c → 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 +4 -4
- data/lib/nanolog.rb +79 -88
- metadata +5 -6
- data/README.md +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 712d776902723bc4ca22b7555f89a92bf6916b7d
|
4
|
+
data.tar.gz: a9ae482a6edae25da796f21dced81fdfc5716db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a15224bff2f9bc1d2d34f57113f6f9204a89487d7476b44474f903e88b72226650046f45eb3f60411f7ae3828faf7a0892ef6b16545e7ea61383505507369c5
|
7
|
+
data.tar.gz: 27afc47807a721c3e44c32a8a6ff34a777a6362ab6c31eaad8284d50b3016068223a73e4826a649391c1e89b9c8bc3cd0d0cefd3c45dd76918e0902b1af5e904
|
data/lib/nanolog.rb
CHANGED
@@ -1,88 +1,79 @@
|
|
1
|
-
# @author Carter Brainerd
|
2
|
-
module NanoLog
|
3
|
-
class Logger
|
4
|
-
|
5
|
-
@logfile = nil
|
6
|
-
|
7
|
-
INFO = ' [INFO] '
|
8
|
-
DEBUG = ' [DEBUG] '
|
9
|
-
FATAL = ' [FATAL] '
|
10
|
-
ERROR = ' [ERROR] '
|
11
|
-
SUCCESS = ' [SUCCESS] '
|
12
|
-
|
13
|
-
#
|
14
|
-
# @param path [String] the path to save the logfile at
|
15
|
-
# @param flush [boolean] whether or not to flush the previous file (if it already exists)
|
16
|
-
#
|
17
|
-
def initialize(path, flush=false)
|
18
|
-
raise NanoLog::NilPathError unless !path.nil?
|
19
|
-
@logfile = File.new(path, 'a') unless flush
|
20
|
-
@logfile = File.new(path, 'w+') if flush
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# Write an `info` message to the log file
|
25
|
-
# @param message [String] the message to log
|
26
|
-
#
|
27
|
-
def info(message='')
|
28
|
-
@logfile.write("#{Time.now}#{INFO}#{message}\n")
|
29
|
-
@logfile.rewind
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Write a `debug` message to the log file
|
34
|
-
# @param message [String] the message to log
|
35
|
-
#
|
36
|
-
def debug(message='')
|
37
|
-
@logfile.write("#{Time.now}#{DEBUG}#{message}\n")
|
38
|
-
@logfile.rewind
|
39
|
-
end
|
40
|
-
|
41
|
-
#
|
42
|
-
# Write a `fatal` message to the log file
|
43
|
-
# @param message [String] the message to log
|
44
|
-
#
|
45
|
-
def fatal(message='')
|
46
|
-
@logfile.write("#{Time.now}#{FATAL}#{message}\n")
|
47
|
-
@logfile.rewind
|
48
|
-
end
|
49
|
-
|
50
|
-
#
|
51
|
-
# Write an `error` message to the log file
|
52
|
-
# @param message [String] the message to log
|
53
|
-
#
|
54
|
-
def error(message='')
|
55
|
-
@logfile.write("#{Time.now}#{ERROR}#{message}\n")
|
56
|
-
@logfile.rewind
|
57
|
-
end
|
58
|
-
|
59
|
-
#
|
60
|
-
# Write a `success` message to the log file
|
61
|
-
# @param message [String] the message to log
|
62
|
-
#
|
63
|
-
def success(message='')
|
64
|
-
@logfile.write("#{Time.now}#{SUCCESS}#{message}\n")
|
65
|
-
@logfile.rewind
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
# This error should only be used if the path in #initialize
|
81
|
-
#
|
82
|
-
class NilPathError < StandardError
|
83
|
-
def initialize(msg="A nil log path is not allowed")
|
84
|
-
super
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
1
|
+
# @author Carter Brainerd
|
2
|
+
module NanoLog
|
3
|
+
class Logger
|
4
|
+
|
5
|
+
@logfile = nil
|
6
|
+
|
7
|
+
INFO = ' [INFO] '
|
8
|
+
DEBUG = ' [DEBUG] '
|
9
|
+
FATAL = ' [FATAL] '
|
10
|
+
ERROR = ' [ERROR] '
|
11
|
+
SUCCESS = ' [SUCCESS] '
|
12
|
+
|
13
|
+
#
|
14
|
+
# @param path [String] the path to save the logfile at
|
15
|
+
# @param flush [boolean] whether or not to flush the previous file (if it already exists)
|
16
|
+
#
|
17
|
+
def initialize(path, flush=false)
|
18
|
+
raise NanoLog::NilPathError unless !path.nil?
|
19
|
+
@logfile = File.new(path, 'a') unless flush
|
20
|
+
@logfile = File.new(path, 'w+') if flush
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Write an `info` message to the log file
|
25
|
+
# @param message [String] the message to log
|
26
|
+
#
|
27
|
+
def info(message='')
|
28
|
+
@logfile.write("#{Time.now}#{INFO}#{message}\n")
|
29
|
+
@logfile.rewind
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Write a `debug` message to the log file
|
34
|
+
# @param message [String] the message to log
|
35
|
+
#
|
36
|
+
def debug(message='')
|
37
|
+
@logfile.write("#{Time.now}#{DEBUG}#{message}\n")
|
38
|
+
@logfile.rewind
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Write a `fatal` message to the log file
|
43
|
+
# @param message [String] the message to log
|
44
|
+
#
|
45
|
+
def fatal(message='')
|
46
|
+
@logfile.write("#{Time.now}#{FATAL}#{message}\n")
|
47
|
+
@logfile.rewind
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Write an `error` message to the log file
|
52
|
+
# @param message [String] the message to log
|
53
|
+
#
|
54
|
+
def error(message='')
|
55
|
+
@logfile.write("#{Time.now}#{ERROR}#{message}\n")
|
56
|
+
@logfile.rewind
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Write a `success` message to the log file
|
61
|
+
# @param message [String] the message to log
|
62
|
+
#
|
63
|
+
def success(message='')
|
64
|
+
@logfile.write("#{Time.now}#{SUCCESS}#{message}\n")
|
65
|
+
@logfile.rewind
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# This error should only be used if the path in #initialize
|
72
|
+
#
|
73
|
+
class NilPathError < StandardError
|
74
|
+
def initialize(msg="A nil log path is not allowed")
|
75
|
+
super
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanolog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carter Brainerd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: cbawsome77@gmail.com
|
@@ -16,7 +16,6 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
-
- README.md
|
20
19
|
- lib/nanolog.rb
|
21
20
|
homepage: http://rubygems.org/gems/nanolog
|
22
21
|
licenses:
|
@@ -33,12 +32,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
33
32
|
version: '0'
|
34
33
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
34
|
requirements:
|
36
|
-
- - "
|
35
|
+
- - ">="
|
37
36
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
37
|
+
version: '0'
|
39
38
|
requirements: []
|
40
39
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.
|
40
|
+
rubygems_version: 2.6.10
|
42
41
|
signing_key:
|
43
42
|
specification_version: 4
|
44
43
|
summary: A small and simple logging gem
|
data/README.md
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# NanoLog [](https://badge.fury.io/rb/nanolog)
|
2
|
-
A simple and extremely small logging library for Ruby.
|
3
|
-
|
4
|
-
## Getting Started
|
5
|
-
|
6
|
-
A simple program using NanoLog looks like so:
|
7
|
-
|
8
|
-
```ruby
|
9
|
-
logger = NanoLog::Logger.new('filepath.log')
|
10
|
-
|
11
|
-
logger.info('informational message')
|
12
|
-
logger.fatal('fatal message')
|
13
|
-
```
|
14
|
-
|
15
|
-
## Installing
|
16
|
-
Install the gem like so:
|
17
|
-
|
18
|
-
`gem install nanolog`
|
19
|
-
|
20
|
-
or add the following line to your `Gemfile`:
|
21
|
-
|
22
|
-
`gem 'nanolog', '~> 0.1.1b'`
|
23
|
-
|
24
|
-
## Documentation
|
25
|
-
Available [here](http://www.rubydoc.info/gems/nanolog/0.1.1b)
|
26
|
-
|
27
|
-
## Authors
|
28
|
-
- Carter Brainerd (cbrnrd) - [GitHub](https://github.com/cbrnrd)
|
29
|
-
|
30
|
-
## Legal stuff
|
31
|
-
NanoLog is licensed under the MIT license (see [LICENSE](https://github.com/cbrnrd/ruby-NanoLog/blob/master/LICENSE))
|
32
|
-
|
33
|
-
## Built with
|
34
|
-
* [Atom](http://atom.io)
|
35
|
-
|
36
|
-
## Thank you
|
37
|
-
|
38
|
-
Thank you for using NanoLog 👏.
|
39
|
-
If you're feeling generous, donations are always appreciated:
|
40
|
-
|
41
|
-
```
|
42
|
-
19XiyrvqyYNLehf89ckBjPQYCfW77F9rx7 (Ƀ, BTC)
|
43
|
-
0xf6f247e4a929890926F88144111f5E27d87bD07a (ETH)
|
44
|
-
LQRUJUpSkmi5BfT6nyPVNKKoLWbnpZ64sL (Ł, LTC)
|
45
|
-
https://www.paypal.me/0xCB (PayPal)
|
46
|
-
```
|