summaryrefslogtreecommitdiff
path: root/posts/2011-02-20-psgichrome.org
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2016-08-10 14:33:04 -0700
committerFranck Cuny <franck.cuny@gmail.com>2016-08-10 20:17:56 -0700
commit8d7d02f42c3947f756c18cb4d37d9d97fbd0d27d (patch)
treea6cecddaaea7e87d901a6c28bebe3a531438f24b /posts/2011-02-20-psgichrome.org
parentMerge branch 'convert-to-org' (diff)
downloadlumberjaph-8d7d02f42c3947f756c18cb4d37d9d97fbd0d27d.tar.gz
convert back to md
Diffstat (limited to 'posts/2011-02-20-psgichrome.org')
-rw-r--r--posts/2011-02-20-psgichrome.org82
1 files changed, 0 insertions, 82 deletions
diff --git a/posts/2011-02-20-psgichrome.org b/posts/2011-02-20-psgichrome.org
deleted file mode 100644
index 8f4bb6a..0000000
--- a/posts/2011-02-20-psgichrome.org
+++ /dev/null
@@ -1,82 +0,0 @@
-Earlier this month, I've read about this extension:
-[[http://www.chromephp.com/][chromePHP]].
-
-The principle of this extension is to allow you to log from your PHP
-application to chrome. You may not be aware, but this is something you
-already have with every web application if you're using Plack. And not
-only for Chrome, but every webkit navigator, and Firefox too!
-
-Let's mimic their page.
-
-** Installation
-
-1. install
- [[http://search.cpan.org/perldoc?Plack::Middleware::ConsoleLogger][Plack::Middleware::ConsoleLogger]]
- with =cpanm Plack::Middleware::ConsoleLogger=
-2. no step 2
-3. no step 3
-4. write a simple PSGI application and log
-
-#+BEGIN_SRC perl
- use strict;
- use warnings;
-
- use Plack::Builder;
-
- my $app = sub {
- my $env = shift;
- my $content = "<html><body>this is foo</body></html>";
- foreach my $k ( keys %$env ) {
- if ( $k =~ /HTTP_/ ) {
- $env->{'psgix.logger'}->({
- level => 'debug',
- message => "$k => " . $env->{$k},
- });
- }
- }
- $env->{'psgix.logger'}->({
- level => 'warn',
- message => 'this is a warning',
- });
- $env->{'psgix.logger'}->({
- level => 'error',
- message => 'this is an error',
- });
- return [ 200, [ 'Content-Type' => 'text/html' ], [$content] ];
- };
-
- builder {
- enable "ConsoleLogger";
- $app;
- }
-#+END_SRC
-
-Load this application with plackup: =plackup chromeplack.pl=
-
-point your browser to http://localhost:5000, activate the javascript
-console.
-
-If this works correctly, you should have a smiliar output in your
-console:
-
-** Dancer
-
-I don't know for other framework, but you can also log to your browser
-with [[http://perldancer.org/][Dancer]].
-
-First, you need to install
-[[http://search.cpan.org/perldoc?Dancer::Logger::PSGI][Dancer::Logger::PSGI]],
-then, in your application, you need to edit the environment file. You'll
-certainly want to change 'development.yml'.
-
-#+BEGIN_EXAMPLE
- logger: "PSGI"
- plack_middlewares:
- -
- - ConsoleLogger
-#+END_EXAMPLE
-
-Now you can start your application (running in a Plack environment, of
-course), and next time you'll use 'warning' or 'debug' or any other
-keyword from Dancer::Logger, the message will end up in your javascript
-console.