While a Datazoom collector prints warning and error messages to the debug console by default, this behavior can be changed by updating the default settings.
Supported Logging Levels
The following logging levels (ordered by increasing verbosity and decreasing severity) can be chosen at runtime:
Logging level |
Remarks |
---|---|
off |
all log messages are suppressed |
error |
show error logs only |
warning |
show warning and error logs |
info |
show info, warning, and error logs |
debug |
show debug, info, warning, and error logs |
verbose |
show verbose debug logs, as well as all other logs |
The default logging level setting is warning, to show both warning and error log messages.
Setting the Logging Level
There are several ways to set the current logging level.
1) Set the desired level as the datazoom_log
query string of the web page URL.
For instance, the collector on this example page will show the default logging behavior when visited as: https://demo.datazoomlabs.com/example_html5_native/index.html
On the other hand, debug and info logging can be enabled through the extra query string as shown below:
https://demo.datazoomlabs.com/example_html5_native/index.html?datazoom_log=debug
2) Set the desired level as the log
query string of the src
URL of a <script>
tag
If a <script>
tag is used to load the Datazoom collector, the developer of the web page can choose to add the log
query string (on the Datazoom collector URL) with the desired logging level. For example:
<script src="https://platform.datazoom.io/beacon/v1/config?configuration_id=xxxxxx&log=info"></script>
Note that the datazoom_
prefix is omitted for query strings on the Datazoom collector URL.
3) Set the desired level by calling the datazoom
root object’s setLogLevel()
method
For example:
<script src="https://platform.datazoom.io/beacon/v1/config?configuration_id=xxxxxx"></script> ... <script> ... datazoom.setLogLevel("verbose"); ... </script>
Note that the same setLogLevel()
method is also available when the datazoom
object is imported from an installed npm
module.
Filtering the Log Messages
The log messages that were printed to the console can be easily filtered for use cases such as:
Including or excluding Datazoom originated log messages based on the presence of the
[DZ]
tag at the beginning of each log message.-
Showing or hiding log messages of specific severity/verbosity levels by using the built-in visibility control of the browser inspector console, as depicted below:
Comments
0 comments
Article is closed for comments.