Plugin Directory

Changeset 640503

Timestamp:
12/17/2012 12:41:08 PM (12 years ago)
Author:
MZAWeb
Message:

Fix Readme

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-log-in-browser/trunk/README.txt

    r640491 r640503  
    1919To log things manually, you can use:
    2020
    21 ´browser()->log  ( $var, $label );´
    22 ´browser()->warn ( $var, $label );´
    23 ´browser()->info ( $var, $label );´
    24 ´browser()->error( $var, $label );´
     21`browser()->log  ( $var, $label );`
     22`browser()->warn ( $var, $label );`
     23`browser()->info ( $var, $label );`
     24`browser()->error( $var, $label );`
    2525
    2626Also, commandas are chainable:
    2727
    28 ´browser()->log( 'This is a log...' )->error( '...and this is an error' );´
     28`browser()->log( 'This is a log...' )->error( '...and this is an error' );`
    2929
    3030For example, to log all your main query's query_vars:
    3131
    32 ´´´add_filter( 'pre_get_posts', 'log_wp_query', 10000 );
     32add_filter( 'pre_get_posts', 'log_wp_query', 10000 );
    3333
    3434function log_wp_query( $query ) {
     
    3737
    3838    return $query;
    39 }´´´
     39}
    4040
    4141= Filters =
     
    4343*wplinb-match-wp-debug*: Set to true to only log when wp_debug is true. To prevent logging when wp_debug is false:
    4444
    45 add_filter( 'wplinb-match-wp-debug', '__return_true' );´
     45`add_filter( 'wplinb-match-wp-debug', '__return_true' );`
    4646
    4747*wplinb-enabled*: To disable logging completely. It takes precedence over *wplinb-match-wp-debug*. To disable logging:
    4848
    49 ´add_filter( 'wplinb-enabled', '__return_false' );´
     49`add_filter( 'wplinb-enabled', '__return_false' );`
    5050
    5151= Profiling =
     
    5353The plugin includes a really simple function to allow you to track execution time of different parts of your code.
    5454
    55 ´browser()->timer( $key, $log = false );´
     55`browser()->timer( $key, $log = false );`
    5656
    5757The first time you call this function with a given $key (string) it will start a timer, and return false. You can start as many timers as you want, using different $key values. You can ignore the second parameter for this first call.
     
    6161Example 1: Sequential use, log manually.
    6262
    63 ´´´browser()->timer( 'Mega loop' );
     63browser()->timer( 'Mega loop' );
    6464for ( $i = 0; $i < 1000000; $i++ ) {
    6565    //do something
    6666}
    6767$time = browser()->timer( 'Mega loop' );
    68 browser()->log( $time, 'The mega loop took:' );´´´
     68browser()->log( $time, 'The mega loop took:' );
    6969
    7070Example 2: Start and end in different places, log automatically.
    7171
    72 ´´´add_action( 'posts_selection', 'start_timer', 100 );
     72add_action( 'posts_selection', 'start_timer', 100 );
    7373add_filter( 'the_posts', 'end_timer', 1, 2 );
    7474
     
    8080    browser()->timer( 'Main query time', true );
    8181    return $posts;
    82 }´´´
     82}
    8383
    8484*This is not a good way of measuring how much time a query takes to run, it's just to illustrate how to use the timer.*
     
    8686In exactly the same way, you can use the function
    8787
    88 ´Browser()->memory( $key, $log = false );´
     88`Browser()->memory( $key, $log = false );`
    8989
    9090to measure delta of memory consumption from your first call and your second call with the same $key.
     
    9292Example:
    9393
    94 ´´´Browser()->memory( 'testing' );
     94Browser()->memory( 'testing' );
    9595$test = array();
    9696for ( $i = 0; $i < 100; $i++ ) {
     
    105105    $test[$i] = md5( rand( 1, $i ) );
    106106}
    107 Browser()->memory( 'testing', true );
    108 ´´´
     107Browser()->memory( 'testing', true );```
    109108
    110109== Installation ==
Note: See TracChangeset for help on using the changeset viewer.