{"id":23721,"date":"2013-08-30T10:50:20","date_gmt":"2013-08-30T10:50:20","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/bang-syslog\/"},"modified":"2013-08-30T14:08:06","modified_gmt":"2013-08-30T14:08:06","slug":"bang-syslog","status":"publish","type":"plugin","link":"https:\/\/szl.wordpress.org\/plugins\/bang-syslog\/","author":1901556,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.2","stable_tag":"trunk","tested":"3.5.2","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"Bang System Logging","header_author":"Marcus Downing","header_description":"","assets_banners_color":"","last_updated":"2013-08-30 14:08:06","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"http:\/\/www.bang-on.net\/","header_author_uri":"http:\/\/www.bang-on.net\/","rating":0,"author_block_rating":0,"active_installs":10,"downloads":1727,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":{"screenshot-2.png":{"filename":"screenshot-2.png","revision":"1566982","resolution":"2","location":"plugin"},"screenshot-1.png":{"filename":"screenshot-1.png","revision":"1566982","resolution":"1","location":"plugin"}},"screenshots":{"1":"<p>The settings page<\/p>","2":"<p>A coloured log file<\/p>"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[94,9231],"plugin_category":[59],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-23721","plugin","type-plugin","status-publish","hentry","plugin_tags-debug","plugin_tags-syslog","plugin_category-utilities-and-tools","plugin_committers-marcusdowning"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/bang-syslog.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/bang-syslog\/trunk\/screenshot-1.png?rev=1566982","caption":"<p>The settings page<\/p>"},{"src":"https:\/\/ps.w.org\/bang-syslog\/trunk\/screenshot-2.png?rev=1566982","caption":"<p>A coloured log file<\/p>"}],"raw_content":"<!--section=description-->\n<p>Enable system logging for WordPress plugin and theme development. This can make it easier to know what your code is doing.<\/p>\n\n<p>Features include:<\/p>\n\n<ul>\n<li>Log to the system log or to a file<\/li>\n<li>Easily append or embed any value in log messages<\/li>\n<li>Coloured logs indicating strings, numbers, arrays, objects, null values etc.<\/li>\n<li>Extract values from arrays of objects<\/li>\n<li>Optionally exclude AJAX, Javascripts, CSS and any other pattern of URLs.<\/li>\n<li>Intercept PHP errors and log strict warnings<\/li>\n<li>Measure memory usage between two points, or the time taken by various parts of your code<\/li>\n<li>Easy to switch off for production sites<\/li>\n<\/ul>\n\n<h4>How to use<\/h4>\n\n<p>Using it is as simple as calling the <code>'log'<\/code> action in your templates or plugin.<\/p>\n\n<pre><code>&lt;?php do_action('log', 'Some log message'); ?&gt;\n<\/code><\/pre>\n\n<p>This will produce a line in your system log:<\/p>\n\n<pre><code>Jun  4 11:23:08 myserver php\/mysite.com[1553]: b8e mysite.com\/path-to-page: Some log message\n<\/code><\/pre>\n\n<p>This includes:<\/p>\n\n<ul>\n<li><code>Jun  4 11:23:08<\/code> - The date and time of the log message<\/li>\n<li><code>myserver<\/code> - The name of this computer<\/li>\n<li><code>php<\/code> - The program that produced the message<\/li>\n<li><code>mysite.com<\/code> - The domain name of the site<\/li>\n<li><code>1553<\/code> - The process ID of the running PHP process<\/li>\n<li><code>b8e<\/code> - A random 3-digit code identifying each page request<\/li>\n<li><code>mysite.com\/path-to-page<\/code> - The URL of the request<\/li>\n<li><code>Some log message<\/code> - Your message<\/li>\n<\/ul>\n\n<p>For more detailed instructions, see the <strong>How to use<\/strong> tab.<\/p>\n\n<h3>How to use<\/h3>\n\n<p>To log a message, use the <code>'log'<\/code> action in your templates or plugins:<\/p>\n\n<pre><code>&lt;?php do_action('log', 'Some log message'); ?&gt;\n<\/code><\/pre>\n\n<p>This will output the log message:<\/p>\n\n<pre><code>Some log message\n<\/code><\/pre>\n\n<h4>Embedding values<\/h4>\n\n<p>If you include extra parameters, they'll be added at the end of the log message:<\/p>\n\n<pre><code>&lt;?php do_action('log', 'A number and a string', 17, 'foo'); ?&gt;\n<\/code><\/pre>\n\n<p>This will produce the log message:<\/p>\n\n<pre><code>A number and a string: 17, foo\n<\/code><\/pre>\n\n<p>The value will be formatted correctly depending on its type: integers, strings, arrays, objects, booleans etc. \nYou don't need to check if values are null or empty, they'll still be output safely.<\/p>\n\n<p>If you put the code <code>%s<\/code> into your log message, then one of the arguments will be dropped into the message:<\/p>\n\n<pre><code>&lt;?php do_action('log', 'I have %s numbers', count($numbers), $numbers); ?&gt;\n<\/code><\/pre>\n\n<p>This will produce the log message:<\/p>\n\n<pre><code>I have 4 numbers: [9, 16, 307, 1]\n<\/code><\/pre>\n\n<h4>Selecting fields<\/h4>\n\n<p>Logging a complete object - such as a WordPress post - can be very large, and sometimes it's only one or two fields you need. \nIf you put a string starting with an exclamation point <code>\"!\"<\/code> followed by a list of field names, they will be selected from the following object.\nThe following will only show the <code>ID<\/code> and <code>post_title<\/code> fields of the post:<\/p>\n\n<pre><code>&lt;?php do_action('log', 'Loaded the post', '!ID,post_title', $post); ?&gt;\n<\/code><\/pre>\n\n<p>This will produce the log message:<\/p>\n\n<pre><code>Loaded the post: {ID: 1932, post_title: Test page}\n<\/code><\/pre>\n\n<p>If you do this with an array of objects, those fields will be selected from each of them. The following will output a list of post <code>ID<\/code>s:<\/p>\n\n<pre><code>&lt;?php do_action('log', 'Loaded %s posts', count($posts), '!ID', $posts); ?&gt;\n<\/code><\/pre>\n\n<p>This will produce the log message:<\/p>\n\n<pre><code>Loaded 3 posts: [1932, 1594, 1103]\n<\/code><\/pre>\n\n<h4>Coloured logs<\/h4>\n\n<p>If you have coloured logging switched on, values will appear in different colours to indicate their type.\nThis can make for quicker scanning of log files. \nTo enable coloured logs, tick the <em>Coloured logs<\/em> checkbox on the settings page.\nThen use the <code>log.sh<\/code> script, included with this plugin, to decode and display the coloured log files.<\/p>\n\n<!--section=installation-->\n<h4>Basic installation<\/h4>\n\n<ol>\n<li>Upload the <code>bang-syslog<\/code> directory into the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Place <code>&lt;?php do_action('log', 'Some log message'); ?&gt;<\/code> in your templates and plugins<\/li>\n<\/ol>\n\n<h4>Early logging for plugin developers<\/h4>\n\n<p>Normally, this plugin can only begin logging once the plugin has loaded.\nIf you're using logging to develop your own plugin, you may find it helpful to activate this plugin earlier.\nPut this line near the bottom of your <code>wp-config.php<\/code> file:<\/p>\n\n<pre><code>require_once(ABSPATH . 'wp-content\/plugins\/bang-syslog\/include.php');\n<\/code><\/pre>\n\n<h4>Using the plugin<\/h4>\n\n<p>The plugin does nothing until it's called in PHP code.\nSee the <strong>How to use<\/strong> tab for more information.<\/p>\n\n<!--section=faq-->\n<dl>\n<dt>What happens when I switch the plugin off?<\/dt>\n<dd><p>The <code>'log'<\/code> action will have no effect.\nNo logs will be written, but there should be no errors either.<\/p><\/dd>\n<dt>Where are my logs?<\/dt>\n<dd><p>By default, the message will be written to the computer's system log.\nThe exact location of this file varies depending on your operating system.\nOn linux, the logs will typically go to <code>\/var\/log\/syslog<\/code> or <code>\/var\/log\/messages<\/code>.<\/p>\n\n<p>The <em>System Logging<\/em> settings page can be used to send the logs instead to the Apache error log, or into a file in your web folder.<\/p><\/dd>\n<dt>My logs are full of garbage!<\/dt>\n<dd><p>Like this?<\/p>\n\n<pre><code>Jun  4 11:23:08 potassium php\/app.k[1553]: \\033[36m\\033[44m97a\\033[0m \\033[32mapp.k\/app-content\/public-order\/policing-football\/www.legislation.gov.uk\/ukpga\/2000\/23\/contents\\033[0m: \\033[37m\\033[1mfs: Setting page params: page = \\033[0m\\033[31mnull\\033[0m\\033[1m, offset = \\033[0m\\033[31mnull\\033[0m\\033[1m, size = \\033[0m\\033[36m10\\033[0m\\033[1m\\033[0m\n<\/code><\/pre>\n\n<p>You have coloured logging switched on. The codes are unix terminal colour codes, which don't show properly in a normal text editor. You need to use the correct tool to view them.<\/p>\n\n<p>You can either switch coloured logging off in the settings page, or you can use the included script <code>log.sh<\/code> to decode the coloured logs.<\/p><\/dd>\n\n<\/dl>","raw_excerpt":"Enable system logging for WordPress plugin and theme development.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/23721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=23721"}],"author":[{"embeddable":true,"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/marcusdowning"}],"wp:attachment":[{"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=23721"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=23721"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=23721"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=23721"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=23721"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/szl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=23721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}