Skip to content

Commit

Permalink
feat: added debug flag in the SuperTokenConfig in the init() for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
IamMayankThakur committed Oct 31, 2023
1 parent 6f4ec90 commit 470866b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion supertokens/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ func LogDebugMessage(message string) {
_, exists := os.LookupEnv("SUPERTOKENS_DEBUG")
if exists {
logger.Printf(formatMessage(message))

}
}
1 change: 1 addition & 0 deletions supertokens/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type TypeInput struct {
AppInfo AppInfo
RecipeList []Recipe
Telemetry *bool
Debug *bool
OnSuperTokensAPIError func(err error, req *http.Request, res http.ResponseWriter)
}

Expand Down
10 changes: 10 additions & 0 deletions supertokens/supertokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"flag"
"net/http"
"os"
"reflect"
"strconv"
"strings"
Expand All @@ -35,6 +36,7 @@ type superTokens struct {
RecipeModules []RecipeModule
OnSuperTokensAPIError func(err error, req *http.Request, res http.ResponseWriter)
Telemetry *bool
Debug *bool
}

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

superTokens.Debug = config.Debug
if superTokens.Debug != nil && *superTokens.Debug {
err := os.Setenv("SUPERTOKENS_DEBUG", "1")
if err != nil {
return err
}
}

LogDebugMessage("Started SuperTokens with debug logging (supertokens.Init called)")

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

0 comments on commit 470866b

Please sign in to comment.