Skip to content

Commit 470866b

Browse files
feat: added debug flag in the SuperTokenConfig in the init() for logging
1 parent 6f4ec90 commit 470866b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

supertokens/logger.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,5 @@ func LogDebugMessage(message string) {
2828
_, exists := os.LookupEnv("SUPERTOKENS_DEBUG")
2929
if exists {
3030
logger.Printf(formatMessage(message))
31-
3231
}
3332
}

supertokens/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type TypeInput struct {
4646
AppInfo AppInfo
4747
RecipeList []Recipe
4848
Telemetry *bool
49+
Debug *bool
4950
OnSuperTokensAPIError func(err error, req *http.Request, res http.ResponseWriter)
5051
}
5152

supertokens/supertokens.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"flag"
2222
"net/http"
23+
"os"
2324
"reflect"
2425
"strconv"
2526
"strings"
@@ -35,6 +36,7 @@ type superTokens struct {
3536
RecipeModules []RecipeModule
3637
OnSuperTokensAPIError func(err error, req *http.Request, res http.ResponseWriter)
3738
Telemetry *bool
39+
Debug *bool
3840
}
3941

4042
// this will be set to true if this is used in a test app environment
@@ -54,6 +56,14 @@ func supertokensInit(config TypeInput) error {
5456
superTokens.OnSuperTokensAPIError = config.OnSuperTokensAPIError
5557
}
5658

59+
superTokens.Debug = config.Debug
60+
if superTokens.Debug != nil && *superTokens.Debug {
61+
err := os.Setenv("SUPERTOKENS_DEBUG", "1")
62+
if err != nil {
63+
return err
64+
}
65+
}
66+
5767
LogDebugMessage("Started SuperTokens with debug logging (supertokens.Init called)")
5868

5969
appInfoJsonString, _ := json.Marshal(config.AppInfo)

0 commit comments

Comments
 (0)