hippware / rn-chat

MIT License
5 stars 0 forks source link

[dev] Logging improvements #4866

Closed bengtan closed 4 years ago

bengtan commented 4 years ago

Whilst debugging 4004, I realised there were some things that we should do to the logging infrastructure in the app. The main new features:

  1. Able to post to bugsnag and RNBGL log from wocky-client code
  2. Able to post to bugsnag and RNBGL log from any component (ie. absinthe-socket)

Depending on what we're doing, we may need to insert logging into wocky-client code OR any component that we use. Furthermore, the logging isn't just console.log()-ish logging, but should also include the ability to post to bugsnag, and to write to the RNBGL log.

I find the RNBGL log very useful because it's persisted on the device and can be retrieved by the user (and sent to the developer). Having this log (almost?) replaces the need to be able to retrieve native OS logs (ie. 'adb logcat', iOS console logs) from a device.

(However, since I've been using the RNBGL log for general purposes, it's a bit misleading to call it the RNBGL log. I've been calling it the 'debug' log (but I'm also thinking of calling it the 'persisted' log).)

Moving forward, I think more and more debug will be written to the RNBGL log. We'll be generalising it sooner or later.

(As an anecdote, my debugging for 4004 resulted in modifying code in wocky-client and absinthe-socket to post to the RNBGL log. And I intend to insert code in absinthe-socket to post to bugsnag when the error condition of 4004 is detected.)

However, implementing these new features also requires:

  1. Able to run wocky-client and tests in nodejs ie. when bugsnag and RNBGL aren't available

so we don't break existing infrastructure.

Then ... as I was looking at the code, I also realised:

  1. Verify/ensure that console.log()-ish logging is stubbed-out when in release mode (ie. !__DEV__). (See actionLogger. What about simpleActionLogger?)

This is already done in logger.ts but it might be insufficient. For example, actionLogger.ts and mst-middlewares.simpleActionLogger both directly call console.log().

And finally:

  1. Tidy-up

Such as removing lots of commented out console.log() calls (which are obsolete) and DRYing up logger.ts.


My proposed solution:

This would allow all wocky-client code to use it.

This would allow any component (ie. absinthe-socket) to post to bugsnag/RNBGL, and disable console logging (in release mode) for all code in components.

And then:

bengtan commented 4 years ago

Not QA-able