Log Overhead in Published Apps

#1

For published expo apps, do console.logs continue to consume device resources (i.e. space and cpu cycles), or are they somehow discarded (for example, does expo no-op the console.log() once it is published)?

The reason I ask is if they do utilize device resources, a developer may want to omit any logging probes from their published apps (depending on how many probes they have). This could be easily accomplished (at the app level) by “fronting” the console.log() with a layer that no-ops in production … however this would be pointless if it expo is already doing this.

The answer to this question is an important point that you may want to consider mentioning in your docs.

As a side topic (which is less important for me), are these logs available in some way in production … say a device-specific technique? I understand that expo does not have a logging strategy from this 3791 post.

Thanks for your help, and thanks for a great product!

#2

Generally console related information can be found on the react native docs.
You are correct in your assumption, console.log can slow down a React Native project.

Some popular methods for silencing console logs are:

Babel plugin
yarn add babel-plugin-transform-remove-console


Brute Force

if (!__DEV__) {
  console.log = () => {};
}

I thought that production builds disabled console.* by default but I couldn’t find anything to verify that. :expressionless:

#3

Thanks for your reply @bacon.

Per your suggestion, I found this React Native Section that briefly mentions logging overhead and disabling.

1 Like