Skip to content

Commit

Permalink
Merge pull request #737 from supertokens/debug-log-change
Browse files Browse the repository at this point in the history
Added docs for `debug` flag in settings
  • Loading branch information
rishabhpoddar authored Nov 3, 2023
2 parents 11d862d + e9e1d93 commit 932e6b3
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 629 deletions.
147 changes: 44 additions & 103 deletions v2/emailpassword/troubleshooting/how-to-troubleshoot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,118 +28,69 @@ This is only available on versions:
- supertokens-python >= v0.6.3
:::

Our backend SDK provides useful logs that can help with debugging. To enable logging, you need to run the SDK in debug mode:
Our backend SDK provides useful logs that can help with debugging. To enable logging, you need to set the debug setting to `true` in the `init` function call:

<BackendSDKTabs>
<TabItem value="nodejs">

<OSTabs isSubTab={true}>
<TabItem value="linux">

```bash
DEBUG=com.supertokens node index.js

# OR

DEBUG=com.supertokens npm start

# OR

DEBUG=com.supertokens yarn start
```
</TabItem>

<TabItem value="mac">

```bash
DEBUG=com.supertokens node index.js

# OR

DEBUG=com.supertokens npm start

# OR

DEBUG=com.supertokens yarn start
```

</TabItem>

<TabItem value="windows">

```batch
SET DEBUG=com.supertokens
node index.js
# OR
SET DEBUG=com.supertokens
npm start
# OR
```tsx
import supertokens from "supertokens-node";

SET DEBUG=com.supertokens
yarn start
supertokens.init({
// highlight-next-line
debug: true,
supertokens: {
connectionURI: "...",
},
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [/*...*/]
});
```
</TabItem>
</OSTabs>

</TabItem>
<TabItem value="go">

<OSTabs isSubTab={true}>
<TabItem value="linux">

```bash
SUPERTOKENS_DEBUG=1 go run main.go
```
</TabItem>
```go
import "github.com/supertokens/supertokens-golang/supertokens"

<TabItem value="mac">
func main() {
supertokens.Init(supertokens.TypeInput{
// highlight-next-line
Debug: true,
Supertokens: &supertokens.ConnectionInfo{
ConnectionURI: "...",
APIKey: "...",
},
})
}

```bash
SUPERTOKENS_DEBUG=1 go run main.go
```

</TabItem>

<TabItem value="windows">

```batch
SET SUPERTOKENS_DEBUG=1
go run main.go
```
</TabItem>
</OSTabs>

</TabItem>
<TabItem value="python">

<OSTabs isSubTab={true}>
<TabItem value="linux">

```bash
SUPERTOKENS_DEBUG=1 python app.py
```
</TabItem>

<TabItem value="mac">

```bash
SUPERTOKENS_DEBUG=1 python app.py
```python
from supertokens_python import init, InputAppInfo, SupertokensConfig

init(
# highlight-next-line
debug=True,
app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
supertokens_config=SupertokensConfig(
connection_uri='...',
api_key='...'
),
framework='flask',
recipe_list=[
#...
]
)
```

</TabItem>

<TabItem value="windows">

```batch
SET SUPERTOKENS_DEBUG=1
python app.py
```
</TabItem>
</OSTabs>

</TabItem>
</BackendSDKTabs>

Expand All @@ -153,16 +104,6 @@ com.supertokens {"t": "2022-04-09T08:44:49.057Z", "sdkVer": "...", "message": "S
- `message`: The log message
- `file`: The file and line number from where this log was generated.

### For non-serverless env
You should see a few logs as soon as you start your backend process in debug mode. If you do not see them, it means:
- Either the env var was not set properly
- `supertokens.init` was not called on the backend. You must call the `init` function for the SDK to work as intended.

### For serverless env
You should see logs as soon as you make at least one API request in to a function that calls `supertokens.init`. If you don't see that, it means:
- Either the env var was not set properly
- You missed calling `supertokens.init` for the serverless function. You must call the `init` function for the SDK to work as intended.

## Enable frontend logs

Add `enableDebugLogs` when calling the `init` function:
Expand Down
147 changes: 44 additions & 103 deletions v2/passwordless/troubleshooting/how-to-troubleshoot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,118 +28,69 @@ This is only available on versions:
- supertokens-python >= v0.6.3
:::

Our backend SDK provides useful logs that can help with debugging. To enable logging, you need to run the SDK in debug mode:
Our backend SDK provides useful logs that can help with debugging. To enable logging, you need to set the debug setting to `true` in the `init` function call:

<BackendSDKTabs>
<TabItem value="nodejs">

<OSTabs isSubTab={true}>
<TabItem value="linux">

```bash
DEBUG=com.supertokens node index.js

# OR

DEBUG=com.supertokens npm start

# OR

DEBUG=com.supertokens yarn start
```
</TabItem>

<TabItem value="mac">

```bash
DEBUG=com.supertokens node index.js

# OR

DEBUG=com.supertokens npm start

# OR

DEBUG=com.supertokens yarn start
```

</TabItem>

<TabItem value="windows">

```batch
SET DEBUG=com.supertokens
node index.js
# OR
SET DEBUG=com.supertokens
npm start
# OR
```tsx
import supertokens from "supertokens-node";

SET DEBUG=com.supertokens
yarn start
supertokens.init({
// highlight-next-line
debug: true,
supertokens: {
connectionURI: "...",
},
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
recipeList: [/*...*/]
});
```
</TabItem>
</OSTabs>

</TabItem>
<TabItem value="go">

<OSTabs isSubTab={true}>
<TabItem value="linux">

```bash
SUPERTOKENS_DEBUG=1 go run main.go
```
</TabItem>
```go
import "github.com/supertokens/supertokens-golang/supertokens"

<TabItem value="mac">
func main() {
supertokens.Init(supertokens.TypeInput{
// highlight-next-line
Debug: true,
Supertokens: &supertokens.ConnectionInfo{
ConnectionURI: "...",
APIKey: "...",
},
})
}

```bash
SUPERTOKENS_DEBUG=1 go run main.go
```

</TabItem>

<TabItem value="windows">

```batch
SET SUPERTOKENS_DEBUG=1
go run main.go
```
</TabItem>
</OSTabs>

</TabItem>
<TabItem value="python">

<OSTabs isSubTab={true}>
<TabItem value="linux">

```bash
SUPERTOKENS_DEBUG=1 python app.py
```
</TabItem>

<TabItem value="mac">

```bash
SUPERTOKENS_DEBUG=1 python app.py
```python
from supertokens_python import init, InputAppInfo, SupertokensConfig

init(
# highlight-next-line
debug=True,
app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
supertokens_config=SupertokensConfig(
connection_uri='...',
api_key='...'
),
framework='flask',
recipe_list=[
#...
]
)
```

</TabItem>

<TabItem value="windows">

```batch
SET SUPERTOKENS_DEBUG=1
python app.py
```
</TabItem>
</OSTabs>

</TabItem>
</BackendSDKTabs>

Expand All @@ -153,16 +104,6 @@ com.supertokens {"t": "2022-04-09T08:44:49.057Z", "sdkVer": "...", "message": "S
- `message`: The log message
- `file`: The file and line number from where this log was generated.

### For non-serverless env
You should see a few logs as soon as you start your backend process in debug mode. If you do not see them, it means:
- Either the env var was not set properly
- `supertokens.init` was not called on the backend. You must call the `init` function for the SDK to work as intended.

### For serverless env
You should see logs as soon as you make at least one API request in to a function that calls `supertokens.init`. If you don't see that, it means:
- Either the env var was not set properly
- You missed calling `supertokens.init` for the serverless function. You must call the `init` function for the SDK to work as intended.

## Enable frontend logs

Add `enableDebugLogs` when calling the `init` function:
Expand Down
Loading

0 comments on commit 932e6b3

Please sign in to comment.