simple_cloud_logging 1.1.15 → 1.1.16
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/examples/example01.rb +16 -8
- data/lib/baselogger.rb +11 -7
- data/lib/locallogger.rb +8 -0
- data/lib/remotelogger.rb +11 -0
- data/lib/simple_cloud_logging.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56d398200fdaf080fb7174b5dcb73f044ca7d441
|
4
|
+
data.tar.gz: 53c7f8eaec31d8b2d4cbd926a36caa414e8e6c9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac0ffc673c4713ee3d857d7d8d3875c80a07c7237906d0287f2fa56d5ebd0a7ce6897f5024a74cc934d59e84f1e9db1a518416f29bdc69513ce6c5737a91ed1e
|
7
|
+
data.tar.gz: 4442f26f6b9fc7be11ccfa62b8989cbf3aaca81caa9fb7ea86ad2c237417a585c5ebba53d00154500af8c7c20228701f27cce4ea02a978742a1d1d547341c229
|
data/examples/example01.rb
CHANGED
@@ -4,15 +4,23 @@ require_relative '../lib/simple_cloud_logging'
|
|
4
4
|
|
5
5
|
logger = BlackStack::LocalLoggerFactory.create('./example01.log')
|
6
6
|
|
7
|
-
logger.
|
8
|
-
@n = 5
|
9
|
-
logger.done
|
7
|
+
logger.reset()
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
while (true)
|
10
|
+
logger.logs("Declare variable... ")
|
11
|
+
@n = 5
|
12
|
+
logger.done
|
13
|
+
|
14
|
+
logger.logs("Check if #{@n.to_s}>5... ")
|
15
|
+
if @n>5
|
16
|
+
logger.yes
|
17
|
+
else
|
18
|
+
logger.no
|
19
|
+
end
|
20
|
+
|
21
|
+
logger.logs("Sleep 60 seconds... ")
|
22
|
+
sleep(60)
|
23
|
+
logger.done
|
16
24
|
end
|
17
25
|
|
18
26
|
#BlackStack::LocalLoggerFactory.save('./example01.log', logger)
|
data/lib/baselogger.rb
CHANGED
@@ -6,21 +6,25 @@ module BlackStack
|
|
6
6
|
METHODS = [METHOD_LOG, METHOD_LOGS, METHOD_LOGF]
|
7
7
|
|
8
8
|
attr_accessor :filename, :nest_level, :number_of_lines_in_current_level, :current_nest_level
|
9
|
+
|
10
|
+
def initialize_attributes()
|
11
|
+
self.nest_level = 0
|
12
|
+
self.current_nest_level = 0
|
13
|
+
self.number_of_lines_in_current_level = 0
|
14
|
+
end
|
9
15
|
|
10
16
|
def initialize(the_filename)
|
11
17
|
self.filename = the_filename
|
12
|
-
self.
|
18
|
+
self.initialize_attributes
|
13
19
|
end
|
14
20
|
|
15
21
|
def reset()
|
16
|
-
self.
|
17
|
-
self.current_nest_level = 0
|
18
|
-
self.number_of_lines_in_current_level = 0
|
22
|
+
self.initialize_attributes
|
19
23
|
end
|
20
24
|
|
21
25
|
def log(s, datetime=nil)
|
22
26
|
t = !datetime.nil? ? datetime : Time.now
|
23
|
-
ltime = t.strftime("%Y
|
27
|
+
ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
|
24
28
|
ltext = ltime + ": " + s + "\r\n"
|
25
29
|
print ltext
|
26
30
|
ltext
|
@@ -28,7 +32,7 @@ module BlackStack
|
|
28
32
|
|
29
33
|
def logs(s, datetime=nil)
|
30
34
|
t = !datetime.nil? ? datetime : Time.now
|
31
|
-
ltime = t.strftime("%Y
|
35
|
+
ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
|
32
36
|
|
33
37
|
ltext = ""
|
34
38
|
self.nest_level += 1
|
@@ -58,7 +62,7 @@ module BlackStack
|
|
58
62
|
|
59
63
|
def logf(s, datetime=nil)
|
60
64
|
t = !datetime.nil? ? datetime : Time.now
|
61
|
-
ltime = t.strftime("%Y
|
65
|
+
ltime = t.strftime("%Y-%m-%d %H:%M:%S").to_s
|
62
66
|
|
63
67
|
ltext = ""
|
64
68
|
if self.number_of_lines_in_current_level > 0
|
data/lib/locallogger.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module BlackStack
|
2
2
|
require_relative './baselogger'
|
3
3
|
class LocalLogger < BlackStack::BaseLogger
|
4
|
+
|
5
|
+
# call the parent class to set the attributes
|
6
|
+
# call the save method to store the new attributes into the data file
|
7
|
+
def reset()
|
8
|
+
super
|
9
|
+
BlackStack::LocalLoggerFactory::save(self.filename, self)
|
10
|
+
end
|
11
|
+
|
4
12
|
def log(s, datetime=nil)
|
5
13
|
ltext = super(s, datetime)
|
6
14
|
File.open(self.filename, 'a') { |file| file.write(ltext) }
|
data/lib/remotelogger.rb
CHANGED
@@ -11,6 +11,17 @@ module BlackStack
|
|
11
11
|
self.api_key = the_api_key
|
12
12
|
end
|
13
13
|
|
14
|
+
# call the parent class to set the attributes
|
15
|
+
# call the save method to store the new attributes into the data file
|
16
|
+
def reset()
|
17
|
+
super
|
18
|
+
url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.4/scl/reset.json"
|
19
|
+
res = BlackStack::Netting::api_call(url, {
|
20
|
+
'api_key' => self.api_key,
|
21
|
+
'filename' => self.filename,
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
14
25
|
def log(s, datetime=nil)
|
15
26
|
ltext = super(s, datetime)
|
16
27
|
url = "#{self.api_protocol}://#{self.api_domain}:#{self.api_port.to_s}/api1.4/scl/log.json"
|
data/lib/simple_cloud_logging.rb
CHANGED
@@ -7,13 +7,13 @@ module BlackStack
|
|
7
7
|
|
8
8
|
|
9
9
|
class LocalLoggerFactory
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
def self.lock()
|
11
|
+
@@fd.flock(File::LOCK_EX)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.release()
|
15
|
+
@@fd.flock(File::LOCK_UN)
|
16
|
+
end
|
17
17
|
|
18
18
|
#
|
19
19
|
def self.create(filename)
|