simple_cloud_logging 1.1.15 → 1.1.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 085b61709dee222254d56b36ab1758a03fe28598
4
- data.tar.gz: be3419091b1a7e658bbf4df854c0849a4bf12d09
3
+ metadata.gz: 56d398200fdaf080fb7174b5dcb73f044ca7d441
4
+ data.tar.gz: 53c7f8eaec31d8b2d4cbd926a36caa414e8e6c9e
5
5
  SHA512:
6
- metadata.gz: 210e11498d59d37d57429cae4627183cf6cdff7efc8d78c44ec0d01a16bfc351834de8cc13bf67fbe5b8cb7f4b56d62f59678459e313246b171f042a34e3c0a8
7
- data.tar.gz: b4a1d74913f0d9bb02d58b241a985a7e990379bb83b98b5f2a78bdb817c5695f38785731f68983b04c708fe8d78d5974e7443c138ab7915dcbadbd96db71003d
6
+ metadata.gz: ac0ffc673c4713ee3d857d7d8d3875c80a07c7237906d0287f2fa56d5ebd0a7ce6897f5024a74cc934d59e84f1e9db1a518416f29bdc69513ce6c5737a91ed1e
7
+ data.tar.gz: 4442f26f6b9fc7be11ccfa62b8989cbf3aaca81caa9fb7ea86ad2c237417a585c5ebba53d00154500af8c7c20228701f27cce4ea02a978742a1d1d547341c229
@@ -4,15 +4,23 @@ require_relative '../lib/simple_cloud_logging'
4
4
 
5
5
  logger = BlackStack::LocalLoggerFactory.create('./example01.log')
6
6
 
7
- logger.logs("Declare variable... ")
8
- @n = 5
9
- logger.done
7
+ logger.reset()
10
8
 
11
- logger.logs("Check if #{@n.to_s}>5... ")
12
- if @n>5
13
- logger.yes
14
- else
15
- logger.no
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.reset()
18
+ self.initialize_attributes
13
19
  end
14
20
 
15
21
  def reset()
16
- self.nest_level = 0
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%m%d%H%M%S").to_s
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%m%d%H%M%S").to_s
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%m%d%H%M%S").to_s
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"
@@ -7,13 +7,13 @@ module BlackStack
7
7
 
8
8
 
9
9
  class LocalLoggerFactory
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
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cloud_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.15
4
+ version: 1.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi