forked from nikushi/twirp-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from GetDutchie/0.4.0
v0.4.0
- Loading branch information
Showing
7 changed files
with
94 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ | |
.rspec_status | ||
Gemfile.lock | ||
.ruby-version | ||
|
||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
module Twirp | ||
module Rails | ||
module Configurations | ||
class Logging | ||
attr_accessor :log_twirp_calls, :log_exceptions, :log_params | ||
|
||
LOG_FORMATTERS = { | ||
json: Twirp::Rails::Logging::Formatters::Json, | ||
key_value: Twirp::Rails::Logging::Formatters::KeyValue | ||
}.freeze | ||
|
||
def log_twirp_calls | ||
@log_twirp_calls ||= true | ||
end | ||
|
||
def log_exceptions | ||
@log_exceptions ||= false | ||
end | ||
|
||
def log_params | ||
@log_params ||= false | ||
end | ||
|
||
def log_formatter | ||
@log_formatter ||= LOG_FORMATTERS[:key_value].new | ||
end | ||
|
||
def log_formatter=(format) | ||
format = format.to_sym | ||
raise ArgumentError, 'Twirp::Rails defined an invalid log formatter' unless LOG_FORMATTERS.keys.include?(format) | ||
|
||
@log_formatter = LOG_FORMATTERS[format].new | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
require "json" | ||
|
||
module Twirp | ||
module Rails | ||
module Logging | ||
module Formatters | ||
class Json | ||
def call(data) | ||
::JSON.dump(data) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Twirp | ||
module Rails | ||
VERSION = "0.3.1" | ||
VERSION = "0.4.0" | ||
end | ||
end |