[
https://issues.apache.org/jira/browse/CB-10791?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15188217#comment-15188217
]
ASF GitHub Bot commented on CB-10791:
-------------------------------------
Github user purplecabbage commented on a diff in the pull request:
https://github.com/apache/cordova-lib/pull/405#discussion_r55602266
--- Diff: cordova-common/src/CordovaLogger.js ---
@@ -153,6 +153,30 @@ CordovaLogger.prototype.setLevel = function (logLevel)
{
};
/**
+ * Adjusts the current logger level according to the passed options.
+ *
+ * @param {Object|Array} opts An object or args array with options
+ *
+ * @return {CordovaLogger} Current instance, to allow calls chaining.
+ */
+CordovaLogger.prototype.adjustLoggerLevel = function (opts) {
+ if (opts instanceof Array) {
+ opts.silent = opts.indexOf('--silent') !== -1;
--- End diff --
Please do not change the type of the object. Why not go with something
concise and easy to understand like :
```
if(Array.isArray(opts)) {
if(opts.indexOf('--verbose') > -1) {
this.setLevel('verbose');
}
else if (opts.indexOf('--silent') > -1) {
this.setLevel('error');
}
}
return this;
```
Note also that I reversed the order of checks in the if/else to reflect
that in the original code --verbose out ranks --silent
> Add adjustLoggerLevel to cordova-common.CordovaLogger
> -----------------------------------------------------
>
> Key: CB-10791
> URL: https://issues.apache.org/jira/browse/CB-10791
> Project: Apache Cordova
> Issue Type: Improvement
> Components: CordovaCommon
> Reporter: Sergey Shakhnazarov
> Assignee: Sergey Shakhnazarov
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]