fdk 0.0.15 → 0.0.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: 54156518eff40553f0490bcf437fa82daf307ce4
4
- data.tar.gz: 73e6aed064fa66529f22777f8788e9292828ff90
3
+ metadata.gz: 65e2394fdcb3ded2289d375557641ce03ad38781
4
+ data.tar.gz: 6587cea06ad9da035c853218d52ffc6af9733fae
5
5
  SHA512:
6
- metadata.gz: b47e349ed1fcc96d5ab2170ad2bafeddeba810246c4457149fd160cb164e4f1dae32b8172ddff9307a11707010a3657770417e6176fe058ba267ebe21431d1bb
7
- data.tar.gz: dc5ba5aaadb49d99ee180098700970f36b8bb258086c723c058d4a8f0718077cf6dfc9898e704fd974c4aec649ef94a310ba8fcfb32591f3bd3ef41f902e199e
6
+ metadata.gz: 85cf5dd30e50be0b4301ceda4954f2fce48c978c69584d10d0e282f5036da583a2ff49bc5610d2b676b511fd929f1410f9e882fa81aac6cad7862cfb7a8855c1
7
+ data.tar.gz: 89d8e019779503fd53d00026dfa412fccc87b4c75eae36f11ff1568b124e287a331338b0a192ed2de62f5e322f96779798c58363f43152a488fba4a4e0048c2a
@@ -36,6 +36,7 @@ module FDK
36
36
  format_response_body(fn_return: yield(context: context, input: input.parsed))
37
37
  good_response
38
38
  rescue StandardError => e
39
+ FDK.log_error(error: e)
39
40
  error_response(error: e)
40
41
  end
41
42
 
@@ -38,8 +38,8 @@ module FDK
38
38
 
39
39
  handle_requests(socket: local_socket, fn_block: block)
40
40
  rescue StandardError => e
41
- STDERR.puts "Error in request handling #{e}"
42
- STDERR.puts e.backtrace
41
+ FDK.log(entry: "Error in request handling #{e}")
42
+ FDK.log(entry: e.backtrace)
43
43
  end
44
44
  local_socket.close
45
45
  end
@@ -7,10 +7,27 @@ require "set"
7
7
  # Executes it with input
8
8
  # Responds with output
9
9
  module FDK
10
- @dbg = ENV["FDK_DEBUG"]
10
+ FDK_LOG_THRESHOLD = "FDK_LOG_THRESHOLD".freeze
11
+ FDK_LOG_DEBUG = 0
12
+ FDK_LOG_DEFAULT = 1
13
+
14
+ def self.log_threshold
15
+ @log_threshold ||= ENV[FDK_LOG_THRESHOLD] ? ENV[FDK_LOG_THRESHOLD].to_i : FDK_LOG_DEFAULT
16
+ end
17
+
18
+ # Writes the entry to STDERR if the log_level >= log_threshold
19
+ # If no log level is specified, 1 is assumed.
20
+ def self.log(entry:, log_level: FDK_LOG_DEFAULT)
21
+ STDERR.puts(entry) if log_level >= log_threshold
22
+ end
23
+
24
+ def self.log_error(error:)
25
+ log(entry: error.message)
26
+ log(entry: error.backtrace.join("\n"), log_level: FDK_LOG_DEBUG)
27
+ end
11
28
 
12
29
  def self.debug(msg)
13
- STDERR.puts(msg) if @dbg
30
+ log(entry: msg, log_level: FDK_LOG_DEBUG)
14
31
  end
15
32
 
16
33
  def self.handle(target:)
@@ -1,3 +1,3 @@
1
1
  module FDK
2
- VERSION = "0.0.15".freeze
2
+ VERSION = "0.0.16".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-10-29 00:00:00.000000000 Z
13
+ date: 2018-11-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.60'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.60'
55
69
  description: Ruby Function Developer Kit for Fn Project.
56
70
  email:
57
71
  - treeder@gmail.com