Module: Util
- Included in:
- AppAbstract, AssetHelper, CloudmunchService, InsightHelper, IntegrationHelper, RoleHelper, ServerHelper
- Defined in:
- lib/cloudmunch_Ruby_sdk_v2/Util.rb,
lib/cloudmunch_Ruby_sdk_v3/Util.rb
Class Method Summary collapse
- .getJSONArgs ⇒ Object
- .log(logger, level, logString) ⇒ Object
- .logClose(logger) ⇒ Object
- .logInit ⇒ Object
- .logIt(logger, log_level, log_level_string, messageString) ⇒ Object
- .openJSONFile(fileNameWithPath) ⇒ Object
Class Method Details
.getJSONArgs ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/cloudmunch_Ruby_sdk_v2/Util.rb', line 64 def Util.getJSONArgs() jsonin = nil loop { case ARGV[0] when '-jsoninput' then ARGV.shift; jsonin = ARGV.shift when /^-/ then usage("Unknown option: #{ARGV[0].inspect}") else break end; } return JSON.load(jsonin); end |
.log(logger, level, logString) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cloudmunch_Ruby_sdk_v2/Util.rb', line 16 def Util.log(logger, level, logString) case level when "debug" logger.debug(logString) when "fatal" logger.fatal(logString) when "error" logger.error(logString) when "warn" logger.warn(logString) when "info" logger.info(logString) else logger.unknown(logString) end end |
.logClose(logger) ⇒ Object
60 61 62 |
# File 'lib/cloudmunch_Ruby_sdk_v2/Util.rb', line 60 def Util.logClose(logger) logger.close end |
.logInit ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/cloudmunch_Ruby_sdk_v2/Util.rb', line 8 def Util.logInit() logger = Logger.new(STDOUT) logger.formatter = proc do |severity, datetime, progname, msg| "#{severity}: #{msg}\n" end return logger end |
.logIt(logger, log_level, log_level_string, messageString) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cloudmunch_Ruby_sdk_v2/Util.rb', line 33 def Util.logIt(logger, log_level, log_level_string, ) case log_level.downcase when "debug" if "debug".eql? log_level_string or "fatal".eql? log_level_string or "error".eql? log_level_string or "warn".eql? log_level_string or "info".eql? log_level_string log(logger, "debug", ) end when "fatal" if "fatal".eql? log_level_string log(logger, "fatal", ) end when "error" if "error".eql? log_level_string log(logger, "error", ) end when "warn" if "warn".eql? log_level_string log(logger, "warn", ) end when "info" if "info".eql? log_level_string log(logger, "info", ) end else log(logger, "unknown", ) end end |
.openJSONFile(fileNameWithPath) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/cloudmunch_Ruby_sdk_v2/Util.rb', line 74 def Util.openJSONFile(fileNameWithPath) begin config = JSON.load(File.open(fileNameWithPath)) return config rescue return false end end |