GM log: Difference between revisions
From GreaseSpot Wiki
Jump to navigationJump to search
deprecation warning |
I want to scream. |
||
Line 2: | Line 2: | ||
<div style="border: 3px dotted; color: red; font-size: 1.2em; padding: 0.5em; margin: 1em; text-align: center"> | <div style="border: 3px dotted; color: red; font-size: 1.2em; padding: 0.5em; margin: 1em; text-align: center"> | ||
'''This feature is deprecated. Script authors are advised to use [https://developer.mozilla.org/en-US/docs/Web/API/console.log console logging] instead.''' | '''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> | </div> | ||
Line 53: | Line 53: | ||
== GM_log and Firebug == | == GM_log and Firebug == | ||
GM_log does not work with Firebug's console anymore. Use <code>console.log</code> instead. | |||
[[Category:API_Reference|L]] | [[Category:API_Reference|L]] |
Revision as of 06:01, 25 May 2014
This feature is deprecated (#1819). Script authors are advised to use console logging instead.
Description
This method provides a very simple logging facility.
If you aren't seeing your messages, make sure you navigate to about:config, and change the values of javascript.options.showInConsole
and javascript.options.strict
to true.
The output is displayed in the error console, and includes the namespace and name of the script before and the provided string value. So, this script:
// ==UserScript== // @name GM_log Example // @namespace http://www.example.com/ // ==/UserScript== GM_log("This is an example of GM_log");
Will produce a line in the error console like:
http://www.example.com/GM_log Example: This is an example of GM_log
Compatibility: Greasemonkey 0.3b+
Syntax
function GM_log( message )
Arguments
message
String
(or any object with a.toString()
method) The message to display in the console.
Returns
undefined
Examples
GM_log("Hello, World!");
GM_log("Warning, " + someInputField.value + "!");
GM_log and Firebug
GM_log does not work with Firebug's console anymore. Use console.log
instead.