|
|
Line 1: |
Line 1: |
| {{DISPLAYTITLE:GM_log}}
| | As of Greasemonkey 4.0, this method has been removed. |
| | | You should use the [https://developer.mozilla.org/en-US/docs/Web/API/console.log console] instead. |
| <div style="border: 3px dotted; color: red; font-size: 1.2em; padding: 0.5em; margin: 1em; text-align: center">
| |
| '''This feature is deprecated ({{GitTicket|1819}}). Script authors are advised to use [https://developer.mozilla.org/en-US/docs/Web/API/console.log console logging] instead.'''
| |
| </div>
| |
| | |
| == Description ==
| |
| | |
| This method provides a very simple logging facility.
| |
| If you aren't seeing your messages, make sure you navigate to [[mozillazine:About:config|about:config]], and change the values of <code>javascript.options.showInConsole</code> and <code>javascript.options.strict</code> to true.
| |
| | |
| The output is displayed in the [https://developer.mozilla.org/en/Error_Console error console], and includes the namespace and name of the script before and the provided string value.
| |
| So, this script:
| |
| | |
| <pre class='sample'>
| |
| // ==UserScript==
| |
| // @name GM_log Example
| |
| // @namespace http://www.example.com/
| |
| // ==/UserScript==
| |
| | |
| GM_log("This is an example of GM_log");
| |
| </pre>
| |
| | |
| Will produce a line in the error console like:
| |
| | |
| <nowiki>http://www.example.com/GM_log Example: This is an example of GM_log</nowiki>
| |
| | |
| Compatibility: [[Version_history#0.3_beta|Greasemonkey 0.3b+]]
| |
| | |
| == Syntax ==
| |
| | |
| {{Function|GM_log|message}}
| |
| | |
| === Arguments ===
| |
| | |
| ; <code>message</code>
| |
| : <code>String</code> (or any object with a <code>.toString()</code> method) The message to display in the console.
| |
| | |
| === Returns ===
| |
| | |
| <code>undefined</code>
| |
| | |
| == Examples ==
| |
| | |
| <pre class='sample'>
| |
| GM_log("Hello, World!");
| |
| </pre>
| |
| | |
| <pre class='sample'>
| |
| GM_log("Warning, " + someInputField.value + "!");
| |
| </pre>
| |
| | |
| == GM_log and Firebug ==
| |
| | |
| GM_log does not work with Firebug's console anymore. Use <code>console.log</code> instead.
| |
| | |
| [[Category:API_Reference|L]]
| |
As of Greasemonkey 4.0, this method has been removed.
You should use the console instead.