Module: FDK
- Defined in:
- lib/fdk/call.rb,
lib/fdk/runner.rb,
lib/fdk/context.rb,
lib/fdk/version.rb,
lib/fdk/function.rb,
lib/fdk/listener.rb,
lib/fdk/support_classes.rb
Overview
Copyright © 2019, 2020 Oracle and/or its affiliates. All rights reserved.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Classes: Call, Config, Context, Function, HTTPContext, InHeaders, Listener, OutHeaders, ParsedInput
Constant Summary collapse
- FDK_LOG_THRESHOLD =
"FDK_LOG_THRESHOLD"
- FDK_LOG_DEBUG =
0
- FDK_LOG_DEFAULT =
1
- VERSION =
"0.0.70"
Class Method Summary collapse
- .debug(msg) ⇒ Object
- .handle(target:) ⇒ Object
-
.log(entry:, log_level: FDK_LOG_DEFAULT) ⇒ Object
Writes the entry to STDERR if the log_level >= log_threshold If no log level is specified, 1 is assumed.
- .log_error(error:) ⇒ Object
- .log_threshold ⇒ Object
Class Method Details
.debug(msg) ⇒ Object
47 48 49 |
# File 'lib/fdk/runner.rb', line 47 def self.debug(msg) log(entry: msg, log_level: FDK_LOG_DEBUG) end |
.handle(target:) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/fdk/runner.rb', line 51 def self.handle(target:) func = Function.new(function: target, format: ENV["FN_FORMAT"]) Listener.new(url: ENV["FN_LISTENER"]).listen do |req, resp| func.call(request: req, response: resp) end end |
.log(entry:, log_level: FDK_LOG_DEFAULT) ⇒ Object
Writes the entry to STDERR if the log_level >= log_threshold If no log level is specified, 1 is assumed.
38 39 40 |
# File 'lib/fdk/runner.rb', line 38 def self.log(entry:, log_level: FDK_LOG_DEFAULT) warn(entry) if log_level >= log_threshold end |
.log_error(error:) ⇒ Object
42 43 44 45 |
# File 'lib/fdk/runner.rb', line 42 def self.log_error(error:) log(entry: error.) log(entry: error.backtrace.join("\n"), log_level: FDK_LOG_DEBUG) end |
.log_threshold ⇒ Object
32 33 34 |
# File 'lib/fdk/runner.rb', line 32 def self.log_threshold @log_threshold ||= ENV[FDK_LOG_THRESHOLD] ? ENV[FDK_LOG_THRESHOLD].to_i : FDK_LOG_DEFAULT end |