You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
5.0 KiB

7 years ago
  1. ---
  2. title: Console
  3. description: Get JavaScript logs in your native logs.
  4. ---
  5. <!---
  6. # license: Licensed to the Apache Software Foundation (ASF) under one
  7. # or more contributor license agreements. See the NOTICE file
  8. # distributed with this work for additional information
  9. # regarding copyright ownership. The ASF licenses this file
  10. # to you under the Apache License, Version 2.0 (the
  11. # "License"); you may not use this file except in compliance
  12. # with the License. You may obtain a copy of the License at
  13. #
  14. # http://www.apache.org/licenses/LICENSE-2.0
  15. #
  16. # Unless required by applicable law or agreed to in writing,
  17. # software distributed under the License is distributed on an
  18. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19. # KIND, either express or implied. See the License for the
  20. # specific language governing permissions and limitations
  21. # under the License.
  22. -->
  23. |Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI |
  24. |:-:|:-:|:-:|:-:|:-:|:-:|
  25. |[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-console/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-console/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-console/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-console/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-console)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-console/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-console.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-console)
  26. # cordova-plugin-console
  27. This plugin is meant to ensure that console.log() is as useful as it can be.
  28. It adds additional function for iOS, Ubuntu, Windows Phone 8, and Windows. If
  29. you are happy with how console.log() works for you, then you probably
  30. don't need this plugin.
  31. This plugin defines a global `console` object.
  32. Although the object is in the global scope, features provided by this plugin
  33. are not available until after the `deviceready` event.
  34. document.addEventListener("deviceready", onDeviceReady, false);
  35. function onDeviceReady() {
  36. console.log("console.log works well");
  37. }
  38. :warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Console%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
  39. ## Installation
  40. cordova plugin add cordova-plugin-console
  41. ### Android Quirks
  42. On some platforms other than Android, console.log() will act on multiple
  43. arguments, such as console.log("1", "2", "3"). However, Android will act only
  44. on the first argument. Subsequent arguments to console.log() will be ignored.
  45. This plugin is not the cause of that, it is a limitation of Android itself.
  46. ## Supported Methods
  47. The plugin support following methods of the `console` object:
  48. - `console.log`
  49. - `console.error`
  50. - `console.exception`
  51. - `console.warn`
  52. - `console.info`
  53. - `console.debug`
  54. - `console.assert`
  55. - `console.dir`
  56. - `console.dirxml`
  57. - `console.time`
  58. - `console.timeEnd`
  59. - `console.table`
  60. ## Partially supported Methods
  61. Methods of the `console` object which implemented, but behave different from browser implementation:
  62. - `console.group`
  63. - `console.groupCollapsed`
  64. The grouping methods are just log name of the group and don't actually indicate grouping for later
  65. calls to `console` object methods.
  66. ## Not supported Methods
  67. Methods of the `console` object which are implemented, but do nothing:
  68. - `console.clear`
  69. - `console.trace`
  70. - `console.groupEnd`
  71. - `console.timeStamp`
  72. - `console.profile`
  73. - `console.profileEnd`
  74. - `console.count`
  75. ## Supported formatting
  76. The following formatting options available:
  77. Format chars:
  78. * `%j` - format arg as JSON
  79. * `%o` - format arg as JSON
  80. * `%c` - format arg as `''`. No color formatting could be done.
  81. * `%%` - replace with `'%'`
  82. Any other char following `%` will format its arg via `toString()`.