Skip to content

Commit

Permalink
Use dev().info for prod logging (#16731)
Browse files Browse the repository at this point in the history
* Use dev().info for prod logging.

* Add comment explaining AMP.setLogLevel().
  • Loading branch information
William Chou committed Jul 16, 2018
1 parent 8ec4b49 commit dfd883b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
24 changes: 12 additions & 12 deletions extensions/amp-bind/0.1/bind-impl.js
Expand Up @@ -231,7 +231,7 @@ export class Bind {
user().error(TAG, 'Failed to merge result from AMP.setState().', e);
}

dev().fine(TAG, 'state:', this.state_);
dev().info(TAG, 'state:', this.state_);

if (opt_skipEval) {
return Promise.resolve();
Expand Down Expand Up @@ -306,7 +306,7 @@ export class Bind {
* @return {!Promise}
*/
setStateWithExpression(expression, scope) {
dev().fine(TAG, 'setState:', `"${expression}"`);
dev().info(TAG, 'setState:', `"${expression}"`);
this.setStatePromise_ = this.evaluateExpression_(expression, scope)
.then(result => this.setState(result))
.then(() => {
Expand All @@ -329,7 +329,7 @@ export class Bind {
* @return {!Promise}
*/
pushStateWithExpression(expression, scope) {
dev().fine(TAG, 'pushState:', expression);
dev().info(TAG, 'pushState:', expression);
return this.evaluateExpression_(expression, scope).then(result => {
// Store the current values of each referenced variable in `expression`
// so that we can restore them on history-pop.
Expand Down Expand Up @@ -368,7 +368,7 @@ export class Bind {
* @return {!Promise}
*/
scanAndApply(added, removed, timeout = 2000) {
dev().fine(TAG, 'rescan:', added, removed);
dev().info(TAG, 'rescan:', added, removed);
const promise = this.removeThenAdd_(added, removed)
.then(bindingsAdded => {
// Don't reevaluate/apply if there are no bindings.
Expand Down Expand Up @@ -403,12 +403,12 @@ export class Bind {
* @private
*/
initialize_(root) {
dev().fine(TAG, 'init');
dev().info(TAG, 'init');
let promise = Promise.all([
this.addMacros_(),
this.addBindingsForNodes_([root])]
).then(results => {
dev().fine(TAG, '⤷', 'Δ:', results);
dev().info(TAG, '⤷', 'Δ:', results);
// Listen for DOM updates (e.g. template render) to rescan for bindings.
root.addEventListener(AmpEvents.DOM_UPDATE, e => this.onDomUpdate_(e));
});
Expand Down Expand Up @@ -797,7 +797,7 @@ export class Bind {
// Throw to reject promise.
throw this.reportWorkerError_(error, `${TAG}: Expression eval failed.`);
} else {
dev().fine(TAG, '⤷', result);
dev().info(TAG, '⤷', result);
return result;
}
});
Expand All @@ -824,7 +824,7 @@ export class Bind {
reportError(userError, elements[0]);
}
});
dev().fine(TAG, 'bindings:', results);
dev().info(TAG, 'bindings:', results);
return results;
});
}
Expand Down Expand Up @@ -942,7 +942,7 @@ export class Bind {
return this.applyBoundElement_(results, boundElement);
});
return Promise.all(promises).then(() => {
dev().fine(TAG, 'updated:', promises.length, 'elements');
dev().info(TAG, 'updated:', promises.length, 'elements');
});
}

Expand All @@ -962,7 +962,7 @@ export class Bind {
});
});
return Promise.all(promises).then(() => {
dev().fine(TAG, 'updated:', promises.length, 'elements');
dev().info(TAG, 'updated:', promises.length, 'elements');
});
}

Expand Down Expand Up @@ -1211,7 +1211,7 @@ export class Bind {
if (parent && parent.tagName == 'AMP-LIST') {
return;
}
dev().fine(TAG, 'dom_update:', target);
dev().info(TAG, 'dom_update:', target);
this.removeThenAdd_([target], [target]).then(() => {
this.dispatchEventForTesting_(BindEvents.RESCAN_TEMPLATE);
});
Expand All @@ -1234,7 +1234,7 @@ export class Bind {
})
.then(added => {
sum += added;
dev().fine(TAG, '⤷', 'Δ:', sum, ', ∑:', this.numberOfBindings());
dev().info(TAG, '⤷', 'Δ:', sum, ', ∑:', this.numberOfBindings());
});
}

Expand Down
8 changes: 4 additions & 4 deletions extensions/amp-list/0.1/amp-list.js
Expand Up @@ -130,7 +130,7 @@ export class AmpList extends AMP.BaseElement {

/** @override */
mutatedAttributesCallback(mutations) {
dev().fine(TAG, 'mutate:', mutations);
dev().info(TAG, 'mutate:', mutations);
const src = mutations['src'];
const state = mutations['state'];
if (src !== undefined) {
Expand Down Expand Up @@ -250,7 +250,7 @@ export class AmpList extends AMP.BaseElement {
* @private
*/
scheduleRender_(items) {
dev().fine(TAG, 'schedule:', items);
dev().info(TAG, 'schedule:', items);
const deferred = new Deferred();
const {promise, resolve: resolver, reject: rejecter} = deferred;
// If there's nothing currently being rendered, schedule a render pass.
Expand All @@ -269,7 +269,7 @@ export class AmpList extends AMP.BaseElement {
doRenderPass_() {
const current = this.renderItems_;
dev().assert(current, 'Nothing to render.');
dev().fine(TAG, 'pass:', current);
dev().info(TAG, 'pass:', current);
const scheduleNextPass = () => {
// If there's a new `renderItems_`, schedule it for render.
if (this.renderItems_ !== current) {
Expand Down Expand Up @@ -336,7 +336,7 @@ export class AmpList extends AMP.BaseElement {
* @private
*/
render_(elements) {
dev().fine(TAG, 'render:', elements);
dev().info(TAG, 'render:', elements);

this.mutateElement(() => {
removeChildren(dev().assertElement(this.container_));
Expand Down
2 changes: 2 additions & 0 deletions src/log.js
Expand Up @@ -600,6 +600,7 @@ export function resetLogConstructorForTesting() {
* 1. Not disabled using `#log=0`.
* 2. Development mode is enabled via `#development=1` or logging is explicitly
* enabled via `#log=D` where D >= 1.
* 3. AMP.setLogLevel(D) is called, where D >= 1.
*
* @param {!Element=} opt_element
* @return {!Log}
Expand Down Expand Up @@ -644,6 +645,7 @@ function getUserLogger(suffix) {
* Enabled in the following conditions:
* 1. Not disabled using `#log=0`.
* 2. Logging is explicitly enabled via `#log=D`, where D >= 2.
* 3. AMP.setLogLevel(D) is called, where D >= 2.
*
* @return {!Log}
*/
Expand Down

0 comments on commit dfd883b

Please sign in to comment.