Skip to content

Commit d42db89

Browse files
committed
Readme.md. Add Logging section
1 parent f84bb95 commit d42db89

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,32 @@ Dynamoid.configure do |config|
914914
end
915915
```
916916

917+
## Logging
918+
919+
There is a config option `logger`. Dynamoid writes requests and
920+
responses to DynamoDB using this logger on the `debug` level. So in
921+
order to troubleshoot and debug issues just set it:
922+
923+
```ruby
924+
class User
925+
include Dynamoid::Document
926+
field name
927+
end
928+
929+
Dynamoid.config.logger.level = :debug
930+
Dynamoid.config.endpoint = 'localhost:8000'
931+
932+
User.create(name: 'Alex')
933+
934+
# => D, [2019-05-12T20:01:07.840051 #75059] DEBUG -- : put_item | Request "{\"TableName\":\"dynamoid_users\",\"Item\":{\"created_at\":{\"N\":\"1557680467.608749\"},\"updated_at\":{\"N\":\"1557680467.608809\"},\"id\":{\"S\":\"1227eea7-2c96-4b8a-90d9-77b38eb85cd0\"}},\"Expected\":{\"id\":{\"Exists\":false}}}" | Response "{}"
935+
936+
# => D, [2019-05-12T20:01:07.842397 #75059] DEBUG -- : (231.28 ms) PUT ITEM - ["dynamoid_users", {:created_at=>0.1557680467608749e10, :updated_at=>0.1557680467608809e10, :id=>"1227eea7-2c96-4b8a-90d9-77b38eb85cd0", :User=>nil}, {}]
937+
```
938+
939+
The first line is a body of HTTP request and response. The second line -
940+
Dynamoid internal logging of API call (`PUT ITEM` in our case) with
941+
timing (231.28 ms).
942+
917943
## Credits
918944

919945
Dynamoid borrows code, structure, and even its name very liberally from the truly amazing [Mongoid](https://github.com/mongoid/mongoid). Without Mongoid to crib from none of this would have been possible, and I hope they don't mind me reusing their very awesome ideas to make DynamoDB just as accessible to the Ruby world as MongoDB.

0 commit comments

Comments
 (0)