djwrapper 0.0.6 → 0.0.7
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.
- data/lib/djwrapper/background_process.rb +22 -9
- data/lib/djwrapper.rb +1 -1
- metadata +1 -1
@@ -19,14 +19,18 @@ module Djwrapper
|
|
19
19
|
log("started.")
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.log(str)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
def self.log(str, options = {})
|
23
|
+
_actually_do_stuff = self.verbose? || options[:important]
|
24
|
+
|
25
|
+
if _actually_do_stuff
|
26
|
+
# +_+ #
|
27
|
+
my_str = " [#{Time.now.utc}] #{str}"
|
28
|
+
# +_+ #
|
29
|
+
if defined?(Rails.logger)
|
30
|
+
Rails.logger.info my_str
|
31
|
+
else
|
32
|
+
puts my_str
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
@@ -34,7 +38,16 @@ module Djwrapper
|
|
34
38
|
start = Time.now
|
35
39
|
yield
|
36
40
|
delta = Time.now - start
|
37
|
-
log("Finished in #{delta} seconds.")
|
41
|
+
log("Finished in #{delta} seconds.", :important => true)
|
42
|
+
end
|
43
|
+
|
44
|
+
# make verbose false by default.
|
45
|
+
# use log("message") to log messages that are not really important
|
46
|
+
# use log("message", :important => true) to log important messages.
|
47
|
+
#
|
48
|
+
# if verbose is set to true, all messages will be logged.
|
49
|
+
def self.verbose?
|
50
|
+
false
|
38
51
|
end
|
39
52
|
|
40
53
|
##############################################################################
|
data/lib/djwrapper.rb
CHANGED