Skip to content

Commit 3c0c34e

Browse files
committed
debug to stderr instead of a file
1 parent 4e7dbdb commit 3c0c34e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
A [pod](https://github.com/babashka/babashka.pods) to interact with AWS using [babashka](https://github.com/borkdude/babashka/).
44

5+
The API is the same as the Java/Python/Go sdks, with clojurized function name, e.g `BatchGetItem` becomes `batch-get-item`.
6+
57
[This file](./babashka/babashka.go) contains the code around receiving/sending bencoded messages from/to babashka.
68

79
Then [this](./gen/generate.clj) generates all the code to use the golang sdk. That might be a bit hacky but allows to have access to most of the AWS sdk really quickly and I believe this is relatively common in Go to get around the lack of generics.
@@ -61,3 +63,7 @@ Whereas in the Python sdk, the paginators are instead generators that lazily loa
6163
This approach is more functional and has been copied here.
6264
To use it you need to use the `get-paginator` fn from the `pod.tzzh.paginator` namespace and pass the fn you need to use as an argument to `get-paginator` as shown in the example above.
6365
The functions that use either `NextContinuationToken`, `NextToken` and `NextMarker` to paginate can currently be paginated.
66+
67+
## Debugging
68+
69+
For debugging set the environment variable `POD_TZZH_AWS_DEBUG=true` and the logs will show in stderr.

main.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ package main
33
import (
44
"github.com/tzzh/pod-tzzh-aws/aws"
55
"github.com/tzzh/pod-tzzh-aws/babashka"
6+
"io/ioutil"
67
"log"
78
"os"
89
)
910

1011
func main() {
11-
f, err := os.OpenFile("/tmp/pod-tzzh-aws.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
12-
if err != nil {
13-
log.Fatalf("error opening file: %v", err)
12+
debug := os.Getenv("POD_TZZH_AWS_DEBUG")
13+
if debug != "true" {
14+
log.SetOutput(ioutil.Discard)
1415
}
15-
defer f.Close()
1616

17-
log.SetOutput(f)
1817
for {
1918
message := babashka.ReadMessage()
2019
aws.ProcessMessage(message)

0 commit comments

Comments
 (0)