raykit 0.0.543 → 0.0.545
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +25 -25
- data/bin/raykit +6 -6
- data/lib/raykit/auto_setup.rb +69 -69
- data/lib/raykit/command.rb +374 -374
- data/lib/raykit/conan/buildinfo.rb +69 -69
- data/lib/raykit/conanpackage.rb +49 -49
- data/lib/raykit/configuration.rb +53 -53
- data/lib/raykit/console.rb +310 -310
- data/lib/raykit/default_content.rb +8 -8
- data/lib/raykit/default_content.txt +219 -219
- data/lib/raykit/dir.rb +127 -127
- data/lib/raykit/dotnet.rb +207 -174
- data/lib/raykit/environment.rb +115 -115
- data/lib/raykit/filesystem.rb +34 -34
- data/lib/raykit/git/commit.rb +16 -16
- data/lib/raykit/git/directory.rb +279 -279
- data/lib/raykit/git/files.rb +46 -46
- data/lib/raykit/git/repositories.rb +89 -89
- data/lib/raykit/git/repository.rb +362 -362
- data/lib/raykit/installer.rb +17 -17
- data/lib/raykit/log.rb +80 -80
- data/lib/raykit/logevent.rb +29 -29
- data/lib/raykit/logger.rb +100 -100
- data/lib/raykit/logging.rb +57 -57
- data/lib/raykit/markdown.rb +21 -21
- data/lib/raykit/msbuild.rb +54 -54
- data/lib/raykit/nugetpackage.rb +54 -54
- data/lib/raykit/nunit.rb +13 -13
- data/lib/raykit/project.rb +343 -343
- data/lib/raykit/rake.rb +39 -39
- data/lib/raykit/runner.rb +42 -42
- data/lib/raykit/secrets.rb +38 -38
- data/lib/raykit/sourceImport.rb +76 -76
- data/lib/raykit/sourceImports.rb +43 -43
- data/lib/raykit/string.rb +18 -18
- data/lib/raykit/symbols.rb +115 -115
- data/lib/raykit/tasks.rb +91 -91
- data/lib/raykit/text.rb +32 -32
- data/lib/raykit/timer.rb +31 -31
- data/lib/raykit/version.rb +97 -95
- data/lib/raykit/vstest.rb +24 -24
- data/lib/raykit/wix.rb +61 -61
- data/lib/raykit/wt.rb +28 -28
- data/lib/raykit/zip.rb +73 -73
- data/lib/raykit.rb +143 -140
- metadata +3 -3
data/lib/raykit/installer.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class Installer
|
5
|
-
def self.make_msi(wxs_file, source_dir, msi_filename)
|
6
|
-
name = "#{File.basename(wxs_file, ".wxs")}"
|
7
|
-
FileUtils.cp(wxs_file, "#{source_dir}/#{File.basename(wxs_file)}")
|
8
|
-
Dir.chdir(source_dir) do
|
9
|
-
run("candle #{File.basename(wxs_file)}")
|
10
|
-
run("light #{name}.wixobj")
|
11
|
-
FileUtils.cp("#{name}.msi", msi_filename)
|
12
|
-
raise "#{msi_filename} does not exist" if !File.exist?(msi_filename)
|
13
|
-
File.delete("#{name}.wixobj")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class Installer
|
5
|
+
def self.make_msi(wxs_file, source_dir, msi_filename)
|
6
|
+
name = "#{File.basename(wxs_file, ".wxs")}"
|
7
|
+
FileUtils.cp(wxs_file, "#{source_dir}/#{File.basename(wxs_file)}")
|
8
|
+
Dir.chdir(source_dir) do
|
9
|
+
run("candle #{File.basename(wxs_file)}")
|
10
|
+
run("light #{name}.wixobj")
|
11
|
+
FileUtils.cp("#{name}.msi", msi_filename)
|
12
|
+
raise "#{msi_filename} does not exist" if !File.exist?(msi_filename)
|
13
|
+
File.delete("#{name}.wixobj")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/raykit/log.rb
CHANGED
@@ -1,80 +1,80 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
|
-
module Raykit
|
4
|
-
class Log < Hash
|
5
|
-
@filename
|
6
|
-
|
7
|
-
def initialize(filename)
|
8
|
-
@filename = filename
|
9
|
-
dir = File.dirname(@filename)
|
10
|
-
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
11
|
-
if File.exist?(@filename)
|
12
|
-
begin
|
13
|
-
data = JSON.parse(File.read(filename))
|
14
|
-
data.each do |k, v|
|
15
|
-
self[k] = v
|
16
|
-
end
|
17
|
-
rescue StandardError
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def save
|
23
|
-
File.open(@filename, "w") { |f| f.write(JSON.generate(self)) }
|
24
|
-
end
|
25
|
-
|
26
|
-
def update_command_time(command, timestamp)
|
27
|
-
command_times = {}
|
28
|
-
command_times = self["command_times"] if key?("command_times")
|
29
|
-
command_times.delete(command) if command_times.key?(command)
|
30
|
-
command_times[command] = timestamp.iso8601
|
31
|
-
self["command_times"] = command_times
|
32
|
-
save
|
33
|
-
end
|
34
|
-
|
35
|
-
def get_command_time(command)
|
36
|
-
if key?("command_times")
|
37
|
-
command_times = self["command_times"]
|
38
|
-
return DateTime.parse(command_times[command]) if command_times.key?(command)
|
39
|
-
end
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.start_task(task_name)
|
44
|
-
puts Rainbow(": #{task_name}").blue.bright
|
45
|
-
MARKDOWN.puts(": #{task_name}")
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.show_value(name, value)
|
49
|
-
puts " " + Rainbow(name).cyan + " " + Rainbow("#{value}").white.bold
|
50
|
-
MARKDOWN.puts("#{name} #{value}")
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.name_value_pair(symbol, the_binding)
|
54
|
-
[symbol.to_s, eval(symbol.to_s, the_binding)]
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.show_table(symbols)
|
58
|
-
max_name_width = 0
|
59
|
-
max_value_width = 0
|
60
|
-
symbols.each { |s|
|
61
|
-
nvp = name_value_pair(s, binding)
|
62
|
-
name = nvp[0]
|
63
|
-
value = nvp[1]
|
64
|
-
max_name_width = name.length if (name.length > max_name_width)
|
65
|
-
if (!value.nil?)
|
66
|
-
max_value_width = value.length if (value.length > max_value_width)
|
67
|
-
end
|
68
|
-
}
|
69
|
-
header = " =".ljust(max_name_width + max_value_width + 5, "=")
|
70
|
-
puts header
|
71
|
-
symbols.each { |s|
|
72
|
-
nvp = name_value_pair(s, binding)
|
73
|
-
name = nvp[0].rjust(max_name_width, " ")
|
74
|
-
value = nvp[1]
|
75
|
-
puts " " + Rainbow(name).cyan + " | " + Rainbow("#{value}").white.bold
|
76
|
-
}
|
77
|
-
puts header
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module Raykit
|
4
|
+
class Log < Hash
|
5
|
+
@filename
|
6
|
+
|
7
|
+
def initialize(filename)
|
8
|
+
@filename = filename
|
9
|
+
dir = File.dirname(@filename)
|
10
|
+
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
11
|
+
if File.exist?(@filename)
|
12
|
+
begin
|
13
|
+
data = JSON.parse(File.read(filename))
|
14
|
+
data.each do |k, v|
|
15
|
+
self[k] = v
|
16
|
+
end
|
17
|
+
rescue StandardError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def save
|
23
|
+
File.open(@filename, "w") { |f| f.write(JSON.generate(self)) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_command_time(command, timestamp)
|
27
|
+
command_times = {}
|
28
|
+
command_times = self["command_times"] if key?("command_times")
|
29
|
+
command_times.delete(command) if command_times.key?(command)
|
30
|
+
command_times[command] = timestamp.iso8601
|
31
|
+
self["command_times"] = command_times
|
32
|
+
save
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_command_time(command)
|
36
|
+
if key?("command_times")
|
37
|
+
command_times = self["command_times"]
|
38
|
+
return DateTime.parse(command_times[command]) if command_times.key?(command)
|
39
|
+
end
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.start_task(task_name)
|
44
|
+
puts Rainbow(": #{task_name}").blue.bright
|
45
|
+
MARKDOWN.puts(": #{task_name}")
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.show_value(name, value)
|
49
|
+
puts " " + Rainbow(name).cyan + " " + Rainbow("#{value}").white.bold
|
50
|
+
MARKDOWN.puts("#{name} #{value}")
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.name_value_pair(symbol, the_binding)
|
54
|
+
[symbol.to_s, eval(symbol.to_s, the_binding)]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.show_table(symbols)
|
58
|
+
max_name_width = 0
|
59
|
+
max_value_width = 0
|
60
|
+
symbols.each { |s|
|
61
|
+
nvp = name_value_pair(s, binding)
|
62
|
+
name = nvp[0]
|
63
|
+
value = nvp[1]
|
64
|
+
max_name_width = name.length if (name.length > max_name_width)
|
65
|
+
if (!value.nil?)
|
66
|
+
max_value_width = value.length if (value.length > max_value_width)
|
67
|
+
end
|
68
|
+
}
|
69
|
+
header = " =".ljust(max_name_width + max_value_width + 5, "=")
|
70
|
+
puts header
|
71
|
+
symbols.each { |s|
|
72
|
+
nvp = name_value_pair(s, binding)
|
73
|
+
name = nvp[0].rjust(max_name_width, " ")
|
74
|
+
value = nvp[1]
|
75
|
+
puts " " + Rainbow(name).cyan + " | " + Rainbow("#{value}").white.bold
|
76
|
+
}
|
77
|
+
puts header
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/raykit/logevent.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
|
5
|
-
module Raykit
|
6
|
-
# :verbose, :debug, :information, :error, :fatal
|
7
|
-
class LogEvent < Hash
|
8
|
-
def initialize(level, messageTemplate, properties)
|
9
|
-
self["Timestamp"] = DateTime.now.iso8601
|
10
|
-
self["Level"] = level
|
11
|
-
self["Message"] = messageTemplate
|
12
|
-
self["MessageTemplate"] = messageTemplate
|
13
|
-
properties["MachineName"] = Raykit::Environment.machine unless properties.key?("MachineName")
|
14
|
-
properties["UserName"] = Raykit::Environment.user unless properties.key?("UserName")
|
15
|
-
properties["RakeDirectory"] = ::Rake.application.original_dir
|
16
|
-
self["Properties"] = properties
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_seq
|
20
|
-
unless ENV["SEQ_SERVER"].nil?
|
21
|
-
cmd_str = "seqcli log -m \"#{self["Message"].gsub('"', "")}\" -l #{self["Level"]} -s #{ENV["SEQ_SERVER"]}"
|
22
|
-
self["Properties"].each do |k, v|
|
23
|
-
cmd_str += " -p \"#{k}=#{v}\""
|
24
|
-
end
|
25
|
-
puts `#{cmd_str}`
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Raykit
|
6
|
+
# :verbose, :debug, :information, :error, :fatal
|
7
|
+
class LogEvent < Hash
|
8
|
+
def initialize(level, messageTemplate, properties)
|
9
|
+
self["Timestamp"] = DateTime.now.iso8601
|
10
|
+
self["Level"] = level
|
11
|
+
self["Message"] = messageTemplate
|
12
|
+
self["MessageTemplate"] = messageTemplate
|
13
|
+
properties["MachineName"] = Raykit::Environment.machine unless properties.key?("MachineName")
|
14
|
+
properties["UserName"] = Raykit::Environment.user unless properties.key?("UserName")
|
15
|
+
properties["RakeDirectory"] = ::Rake.application.original_dir
|
16
|
+
self["Properties"] = properties
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_seq
|
20
|
+
unless ENV["SEQ_SERVER"].nil?
|
21
|
+
cmd_str = "seqcli log -m \"#{self["Message"].gsub('"', "")}\" -l #{self["Level"]} -s #{ENV["SEQ_SERVER"]}"
|
22
|
+
self["Properties"].each do |k, v|
|
23
|
+
cmd_str += " -p \"#{k}=#{v}\""
|
24
|
+
end
|
25
|
+
puts `#{cmd_str}`
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/raykit/logger.rb
CHANGED
@@ -1,100 +1,100 @@
|
|
1
|
-
require "logger"
|
2
|
-
require "rainbow"
|
3
|
-
|
4
|
-
module Raykit
|
5
|
-
class Logger
|
6
|
-
def initialize(logger_array)
|
7
|
-
@logger_array = logger_array
|
8
|
-
#@loggerB = loggerB
|
9
|
-
end
|
10
|
-
|
11
|
-
def level=(level)
|
12
|
-
@logger_array.each do |logger|
|
13
|
-
logger.level = level
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def debug(message)
|
18
|
-
@logger_array.each do |logger|
|
19
|
-
logger.debug(message)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def info(message)
|
24
|
-
@logger_array.each do |logger|
|
25
|
-
logger.info(message)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def warn(message)
|
30
|
-
@logger_array.each do |logger|
|
31
|
-
logger.warn(message)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def error(message)
|
36
|
-
@logger_array.each do |logger|
|
37
|
-
logger.error(message)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def fatal(message)
|
42
|
-
@logger_array.each do |logger|
|
43
|
-
logger.fatal(message)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.strip_ansi_codes(str) # Strips ANSI color codes
|
48
|
-
str.gsub(/\e\[[0-9;]*m/, "")
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.default
|
52
|
-
Raykit::Logger.new([Raykit::Logger::console_logger]) #, Raykit::Logger::file_logger])
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.console_logger
|
56
|
-
console_logger = ::Logger.new(STDOUT)
|
57
|
-
console_logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
58
|
-
"#{Raykit::Symbols::get_severity_symbol(_severity)} #{msg}\n"
|
59
|
-
end
|
60
|
-
console_logger
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.file_logger
|
64
|
-
log_dir = Environment::log_dir
|
65
|
-
FileUtils.mkdir_p(log_dir) if (!Dir.exist?(log_dir))
|
66
|
-
#FileUtils.mkdir("log") if (!Dir.exist?("log"))
|
67
|
-
file_logger = ::Logger.new(File.new(LOG_FILENAME, "w"))
|
68
|
-
file_logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
69
|
-
"#{strip_ansi_codes(msg)}\n"
|
70
|
-
end
|
71
|
-
file_logger
|
72
|
-
end
|
73
|
-
end # class Logger
|
74
|
-
end # module Raykit
|
75
|
-
|
76
|
-
DEFAULT_LOGGER = Raykit::Logger::default
|
77
|
-
|
78
|
-
def set_log_level(level)
|
79
|
-
DEFAULT_LOGGER.level = level
|
80
|
-
end
|
81
|
-
|
82
|
-
def log_debug(message)
|
83
|
-
DEFAULT_LOGGER.debug(message)
|
84
|
-
end
|
85
|
-
|
86
|
-
def log_info(message)
|
87
|
-
DEFAULT_LOGGER.info(message)
|
88
|
-
end
|
89
|
-
|
90
|
-
def log_warn(message)
|
91
|
-
DEFAULT_LOGGER.warn(message)
|
92
|
-
end
|
93
|
-
|
94
|
-
def log_error(message)
|
95
|
-
DEFAULT_LOGGER.error(message)
|
96
|
-
end
|
97
|
-
|
98
|
-
def log_fatal(message)
|
99
|
-
DEFAULT_LOGGER.fatal(message)
|
100
|
-
end
|
1
|
+
require "logger"
|
2
|
+
require "rainbow"
|
3
|
+
|
4
|
+
module Raykit
|
5
|
+
class Logger
|
6
|
+
def initialize(logger_array)
|
7
|
+
@logger_array = logger_array
|
8
|
+
#@loggerB = loggerB
|
9
|
+
end
|
10
|
+
|
11
|
+
def level=(level)
|
12
|
+
@logger_array.each do |logger|
|
13
|
+
logger.level = level
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def debug(message)
|
18
|
+
@logger_array.each do |logger|
|
19
|
+
logger.debug(message)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def info(message)
|
24
|
+
@logger_array.each do |logger|
|
25
|
+
logger.info(message)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def warn(message)
|
30
|
+
@logger_array.each do |logger|
|
31
|
+
logger.warn(message)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def error(message)
|
36
|
+
@logger_array.each do |logger|
|
37
|
+
logger.error(message)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def fatal(message)
|
42
|
+
@logger_array.each do |logger|
|
43
|
+
logger.fatal(message)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.strip_ansi_codes(str) # Strips ANSI color codes
|
48
|
+
str.gsub(/\e\[[0-9;]*m/, "")
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.default
|
52
|
+
Raykit::Logger.new([Raykit::Logger::console_logger]) #, Raykit::Logger::file_logger])
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.console_logger
|
56
|
+
console_logger = ::Logger.new(STDOUT)
|
57
|
+
console_logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
58
|
+
"#{Raykit::Symbols::get_severity_symbol(_severity)} #{msg}\n"
|
59
|
+
end
|
60
|
+
console_logger
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.file_logger
|
64
|
+
log_dir = Environment::log_dir
|
65
|
+
FileUtils.mkdir_p(log_dir) if (!Dir.exist?(log_dir))
|
66
|
+
#FileUtils.mkdir("log") if (!Dir.exist?("log"))
|
67
|
+
file_logger = ::Logger.new(File.new(LOG_FILENAME, "w"))
|
68
|
+
file_logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
69
|
+
"#{strip_ansi_codes(msg)}\n"
|
70
|
+
end
|
71
|
+
file_logger
|
72
|
+
end
|
73
|
+
end # class Logger
|
74
|
+
end # module Raykit
|
75
|
+
|
76
|
+
DEFAULT_LOGGER = Raykit::Logger::default
|
77
|
+
|
78
|
+
def set_log_level(level)
|
79
|
+
DEFAULT_LOGGER.level = level
|
80
|
+
end
|
81
|
+
|
82
|
+
def log_debug(message)
|
83
|
+
DEFAULT_LOGGER.debug(message)
|
84
|
+
end
|
85
|
+
|
86
|
+
def log_info(message)
|
87
|
+
DEFAULT_LOGGER.info(message)
|
88
|
+
end
|
89
|
+
|
90
|
+
def log_warn(message)
|
91
|
+
DEFAULT_LOGGER.warn(message)
|
92
|
+
end
|
93
|
+
|
94
|
+
def log_error(message)
|
95
|
+
DEFAULT_LOGGER.error(message)
|
96
|
+
end
|
97
|
+
|
98
|
+
def log_fatal(message)
|
99
|
+
DEFAULT_LOGGER.fatal(message)
|
100
|
+
end
|
data/lib/raykit/logging.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
require "logger"
|
5
|
-
|
6
|
-
module Raykit
|
7
|
-
class Logging
|
8
|
-
attr_accessor :enabled, :loggers
|
9
|
-
|
10
|
-
# Logger::Severity DEBUG,ERROR,FATAL,INFO,UNKOWN,WARN
|
11
|
-
# defaults to WARN
|
12
|
-
attr_accessor :severity
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
@enabled = true
|
16
|
-
@loggers = {}
|
17
|
-
@severity = ::Logger::Severity::WARN
|
18
|
-
end
|
19
|
-
|
20
|
-
def set_severity_as_string(severity)
|
21
|
-
@severity = ::Logger::Severity::DEBUG if severity == "debug"
|
22
|
-
@severity = ::Logger::Severity::INFO if severity == "info"
|
23
|
-
@severity = ::Logger::Severity::WARN if severity == "warn"
|
24
|
-
@severity = ::Logger::Severity::ERROR if severity == "error"
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_logger(context)
|
28
|
-
unless loggers.key?(context)
|
29
|
-
Dir.chdir(Environment.get_dev_dir("log")) do
|
30
|
-
# start the log over whenever the log exceeds 100 megabytes in size
|
31
|
-
loggers[context] = Logger.new("#{context}.log", 0, 100 * 1024 * 1024)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
loggers[context]
|
35
|
-
end
|
36
|
-
|
37
|
-
def log(context, level, message)
|
38
|
-
if @enabled
|
39
|
-
logger = get_logger(context)
|
40
|
-
case level
|
41
|
-
when Logger::Severity::DEBUG
|
42
|
-
logger.debug(message)
|
43
|
-
when Logger::Severity::INFO
|
44
|
-
logger.info(message)
|
45
|
-
when Logger::Severity::WARN
|
46
|
-
logger.warn(message)
|
47
|
-
when Logger::Severity::ERROR
|
48
|
-
logger.error(message)
|
49
|
-
when Logger::Severity::FATAL
|
50
|
-
logger.fatal(message)
|
51
|
-
else
|
52
|
-
logger.unknown(message)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "logger"
|
5
|
+
|
6
|
+
module Raykit
|
7
|
+
class Logging
|
8
|
+
attr_accessor :enabled, :loggers
|
9
|
+
|
10
|
+
# Logger::Severity DEBUG,ERROR,FATAL,INFO,UNKOWN,WARN
|
11
|
+
# defaults to WARN
|
12
|
+
attr_accessor :severity
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@enabled = true
|
16
|
+
@loggers = {}
|
17
|
+
@severity = ::Logger::Severity::WARN
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_severity_as_string(severity)
|
21
|
+
@severity = ::Logger::Severity::DEBUG if severity == "debug"
|
22
|
+
@severity = ::Logger::Severity::INFO if severity == "info"
|
23
|
+
@severity = ::Logger::Severity::WARN if severity == "warn"
|
24
|
+
@severity = ::Logger::Severity::ERROR if severity == "error"
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_logger(context)
|
28
|
+
unless loggers.key?(context)
|
29
|
+
Dir.chdir(Environment.get_dev_dir("log")) do
|
30
|
+
# start the log over whenever the log exceeds 100 megabytes in size
|
31
|
+
loggers[context] = Logger.new("#{context}.log", 0, 100 * 1024 * 1024)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
loggers[context]
|
35
|
+
end
|
36
|
+
|
37
|
+
def log(context, level, message)
|
38
|
+
if @enabled
|
39
|
+
logger = get_logger(context)
|
40
|
+
case level
|
41
|
+
when Logger::Severity::DEBUG
|
42
|
+
logger.debug(message)
|
43
|
+
when Logger::Severity::INFO
|
44
|
+
logger.info(message)
|
45
|
+
when Logger::Severity::WARN
|
46
|
+
logger.warn(message)
|
47
|
+
when Logger::Severity::ERROR
|
48
|
+
logger.error(message)
|
49
|
+
when Logger::Severity::FATAL
|
50
|
+
logger.fatal(message)
|
51
|
+
else
|
52
|
+
logger.unknown(message)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/raykit/markdown.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
module Raykit
|
2
|
-
class Markdown
|
3
|
-
attr_accessor :text
|
4
|
-
|
5
|
-
def initialize()
|
6
|
-
@text = ""
|
7
|
-
end
|
8
|
-
|
9
|
-
def puts(line)
|
10
|
-
@text = @text + "\n" + line
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_s()
|
14
|
-
@text
|
15
|
-
end
|
16
|
-
|
17
|
-
def save_as(filename)
|
18
|
-
#File.write("rake.md", @text)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
module Raykit
|
2
|
+
class Markdown
|
3
|
+
attr_accessor :text
|
4
|
+
|
5
|
+
def initialize()
|
6
|
+
@text = ""
|
7
|
+
end
|
8
|
+
|
9
|
+
def puts(line)
|
10
|
+
@text = @text + "\n" + line
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s()
|
14
|
+
@text
|
15
|
+
end
|
16
|
+
|
17
|
+
def save_as(filename)
|
18
|
+
#File.write("rake.md", @text)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|