awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
921 stars 267 forks source link

Does AppSyncClient use Amplify Logger? #355

Open hisham opened 5 years ago

hisham commented 5 years ago

Do you want to request a feature or report a bug? bug

What is the current behavior? Setting Amplify.Logger.LOG_LEVEL = 'DEBUG'; does not emit any appsync related logs.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

Set Amplify.Logger.LOG_LEVEL = 'DEBUG'; and watch the console logs.

What is the expected behavior?

I should be able to see some appsync related logs.

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions? Latest versions.

greimela commented 5 years ago

I asked myself the same question and figured out the following: The AppSync client uses https://www.npmjs.com/package/debug for logging. You can enable the output

hisham commented 5 years ago

Cool thanks! I"m using the browser. Tried to set localStorage.debug = 'aws-appsync:*' in the console but nothing new was being logged. Setting window.LOG_LEVEL = 'DEBUG' however in the console enabled all other amplify logging...

greimela commented 5 years ago

I didn't set it using the console, but using the DevTools. There you should be able to add an entry in your local storage with key debug and value aws-appsync:*.

hisham commented 5 years ago

Still not working for me :S. Attached is screenshot of my localStorage setting in Chrome DevTools. Still no logs appear in the console.

greimela commented 5 years ago

Strange. Are you sure you are using the latest version? Logging has been introduced in aws-appsync@1.7.0.

hisham commented 5 years ago

Yes I am running 1.7.1. I do see the 'debug' package as a dependency in the aws-appsync package inside my node_modules.

manueliglesias commented 5 years ago

@hisham could it be possible that you have some sort of filtering of log messages active?

image

@greimela instructions are correct and work for me too

can you try also using aws-appsync:*,* as the value? That should show some other libraries log messages too

hisham commented 5 years ago

Nope nothing outputs and I don't have any filters. You can test the app yourself at https://econsults.seemaeye.com.

hisham commented 5 years ago

Actually running in dev mode (localhost) and with aws-appsync:, produces debug logs from sockjs-client:main:

seema institute 2019-02-19 15-40-11

But I don't see appsync specific logs. And it seems the debug logs are disabled in production deployed version regardless of local storage setting.

manueliglesias commented 5 years ago

Regarding not seeing the messages in prod, I think your bundler might not be including the debug module maybe?

Actually running in dev mode (localhost) and with aws-appsync:, produces debug logs from sockjs-client:main:

I noticed it is missing the '', can you try with `aws-appsync:`

isocra commented 5 years ago

How do you enable this in Expo/React Native?

I've tried in my typescript code to put

import { debug } from 'debug';
debug.enable('aws-appsync:*');

But this doesn't have any effect.