As a perl veteran I am used to using the built-in "warn" function to write to STDERR. Under mod_perl/Apache this prints to the web server's error log. Using my dancer app like this: plackup -L Shotgun app.pl If I have a "warn" anywhere in my app, I get an error message: Error trace status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.2/Plack/Middleware/StackTrace.pm line 27 However, if I print STDERR "msg"; that works. My question is: what happened to warn? Can it be fixed so that it writes to STDERR instead of triggering an error message? I know about the "warning" function but it's really hard to change 10 years of muscle memory! Thanks, Brian
check environments/development.yml Thanks On 2011/1/22 9:08, Brian E. Lozier wrote:
As a perl veteran I am used to using the built-in "warn" function to write to STDERR. Under mod_perl/Apache this prints to the web server's error log. Using my dancer app like this:
plackup -L Shotgun app.pl
If I have a "warn" anywhere in my app, I get an error message:
Error trace
status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.2/Plack/Middleware/StackTrace.pm line 27
However, if I print STDERR "msg"; that works. My question is: what happened to warn? Can it be fixed so that it writes to STDERR instead of triggering an error message?
I know about the "warning" function but it's really hard to change 10 years of muscle memory!
Thanks, Brian _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-- Fayland Lam // http://www.fayland.org/
This is very helpful, thank you. On Fri, Jan 21, 2011 at 5:16 PM, Fayland Lam <fayland@gmail.com> wrote:
check environments/development.yml
Thanks
On 2011/1/22 9:08, Brian E. Lozier wrote:
As a perl veteran I am used to using the built-in "warn" function to write to STDERR. Under mod_perl/Apache this prints to the web server's error log. Using my dancer app like this:
plackup -L Shotgun app.pl
If I have a "warn" anywhere in my app, I get an error message:
Error trace
status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.2/Plack/Middleware/StackTrace.pm line 27
However, if I print STDERR "msg"; that works. My question is: what happened to warn? Can it be fixed so that it writes to STDERR instead of triggering an error message?
I know about the "warning" function but it's really hard to change 10 years of muscle memory!
Thanks, Brian _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-- Fayland Lam // http://www.fayland.org/
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Hi Brian. You can use the exported "debug", "warning" and "error" functions to output to the logger with a certain severity which is easier to identify in the log. This includes other useful information such as timing. Hope that helps. On Sat, Jan 22, 2011 at 3:08 AM, Brian E. Lozier <brian@massassi.com> wrote:
As a perl veteran I am used to using the built-in "warn" function to write to STDERR. Under mod_perl/Apache this prints to the web server's error log. Using my dancer app like this:
plackup -L Shotgun app.pl
If I have a "warn" anywhere in my app, I get an error message:
Error trace
status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.2/Plack/Middleware/StackTrace.pm line 27
However, if I print STDERR "msg"; that works. My question is: what happened to warn? Can it be fixed so that it writes to STDERR instead of triggering an error message?
I know about the "warning" function but it's really hard to change 10 years of muscle memory!
Thanks, Brian _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Hi, there are different topics involved here. The first one regards the version of Dancer you're running. I tried to start a sample application with "dancer -a Whatever" and added a warn call in the only route handler, but did not get your error. I ran my example with Dancer 1.2002 and the result was the error I expected, which leads us to the following point. The second topic deals with warnings promoted to fatal errors. This is triggered by the "warnings" setting, whose documentation is in Dancer::Config. This setting is enabled by default in the "development" environment, so you should turn this off to get rid of the errors. From what I understood, this is meant to be a useful feature to ensure that you don't get warnings from modules, etc. which you might want to catch as soon as you're in the development process. About your muscle memory, if you want to use "warn" instead of "warning" I think that your best option is to propose a patch which I suppose could be developed along the following lines: * read how to contribute to the project in https://github.com/sukria/Dancer/blob/devel/lib/Dancer/Development.pod * add a configuration option "warn_as_warning" in lib/Dancer/Config.pm * use this configuration option in lib/Dancer/Route.pm subroutine "execute" like this: # ------------------------------------- sub execute { my ($self) = @_; - if (Dancer::Config::setting('warnings')) { + if (Dancer::Config::setting('warn_as_warning')) { + local $SIG{__WARN__} = \&Dancer::Logger::warning; + return $self->code->(); + } + elsif (Dancer::Config::setting('warnings')) { my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; my $content = $self->code->(); # ------------------------------------- * write tests Anyway, separating how you send warnings in your web application from how you (or others) do that in the modules you use might be very useful to detect problems early... a good reason to teach something new to your muscle memory! Cheers, Flavio. On Sat, Jan 22, 2011 at 2:08 AM, Brian E. Lozier <brian@massassi.com> wrote:
As a perl veteran I am used to using the built-in "warn" function to write to STDERR. Under mod_perl/Apache this prints to the web server's error log. Using my dancer app like this:
plackup -L Shotgun app.pl
If I have a "warn" anywhere in my app, I get an error message:
Error trace
status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.2/Plack/Middleware/StackTrace.pm line 27
However, if I print STDERR "msg"; that works. My question is: what happened to warn? Can it be fixed so that it writes to STDERR instead of triggering an error message?
I know about the "warning" function but it's really hard to change 10 years of muscle memory!
Thanks, Brian _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
$VERSION = '1.2003'; Looks like I'm using 1.2003. Thanks for your detailed reply, I appreciate it. On Sat, Jan 22, 2011 at 12:53 PM, Flavio Poletti <polettix@gmail.com> wrote:
Hi, there are different topics involved here. The first one regards the version of Dancer you're running. I tried to start a sample application with "dancer -a Whatever" and added a warn call in the only route handler, but did not get your error. I ran my example with Dancer 1.2002 and the result was the error I expected, which leads us to the following point. The second topic deals with warnings promoted to fatal errors. This is triggered by the "warnings" setting, whose documentation is in Dancer::Config. This setting is enabled by default in the "development" environment, so you should turn this off to get rid of the errors. From what I understood, this is meant to be a useful feature to ensure that you don't get warnings from modules, etc. which you might want to catch as soon as you're in the development process. About your muscle memory, if you want to use "warn" instead of "warning" I think that your best option is to propose a patch which I suppose could be developed along the following lines: * read how to contribute to the project in https://github.com/sukria/Dancer/blob/devel/lib/Dancer/Development.pod * add a configuration option "warn_as_warning" in lib/Dancer/Config.pm * use this configuration option in lib/Dancer/Route.pm subroutine "execute" like this: # ------------------------------------- sub execute { my ($self) = @_;
- if (Dancer::Config::setting('warnings')) { + if (Dancer::Config::setting('warn_as_warning')) { + local $SIG{__WARN__} = \&Dancer::Logger::warning; + return $self->code->(); + } + elsif (Dancer::Config::setting('warnings')) { my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; my $content = $self->code->(); # ------------------------------------- * write tests Anyway, separating how you send warnings in your web application from how you (or others) do that in the modules you use might be very useful to detect problems early... a good reason to teach something new to your muscle memory! Cheers, Flavio.
On Sat, Jan 22, 2011 at 2:08 AM, Brian E. Lozier <brian@massassi.com> wrote:
As a perl veteran I am used to using the built-in "warn" function to write to STDERR. Under mod_perl/Apache this prints to the web server's error log. Using my dancer app like this:
plackup -L Shotgun app.pl
If I have a "warn" anywhere in my app, I get an error message:
Error trace
status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.2/Plack/Middleware/StackTrace.pm line 27
However, if I print STDERR "msg"; that works. My question is: what happened to warn? Can it be fixed so that it writes to STDERR instead of triggering an error message?
I know about the "warning" function but it's really hard to change 10 years of muscle memory!
Thanks, Brian _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
You're welcome :) I think that there is some red flag here, are you able to craft a minimal example that shows your error exactly? As I said, I tried to replicate it by creating a brand new project and inserting a simple warn in the route that was created, but I did not receive the error message you reported. Cheers, Flavio. On Sun, Jan 23, 2011 at 9:08 AM, Brian E. Lozier <brian@massassi.com> wrote:
$VERSION = '1.2003';
Looks like I'm using 1.2003.
Thanks for your detailed reply, I appreciate it.
On Sat, Jan 22, 2011 at 12:53 PM, Flavio Poletti <polettix@gmail.com> wrote:
Hi, there are different topics involved here. The first one regards the version of Dancer you're running. I tried to start a sample application with "dancer -a Whatever" and added a warn call in the only route handler, but did not get your error. I ran my example with Dancer 1.2002 and the result was the error I expected, which leads us to the following point. The second topic deals with warnings promoted to fatal errors. This is triggered by the "warnings" setting, whose documentation is in Dancer::Config. This setting is enabled by default in the "development" environment, so you should turn this off to get rid of the errors. From what I understood, this is meant to be a useful feature to ensure that you don't get warnings from modules, etc. which you might want to catch as soon as you're in the development process. About your muscle memory, if you want to use "warn" instead of "warning" I think that your best option is to propose a patch which I suppose could be developed along the following lines: * read how to contribute to the project in https://github.com/sukria/Dancer/blob/devel/lib/Dancer/Development.pod * add a configuration option "warn_as_warning" in lib/Dancer/Config.pm * use this configuration option in lib/Dancer/Route.pm subroutine "execute" like this: # ------------------------------------- sub execute { my ($self) = @_;
- if (Dancer::Config::setting('warnings')) { + if (Dancer::Config::setting('warn_as_warning')) { + local $SIG{__WARN__} = \&Dancer::Logger::warning; + return $self->code->(); + } + elsif (Dancer::Config::setting('warnings')) { my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; my $content = $self->code->(); # ------------------------------------- * write tests Anyway, separating how you send warnings in your web application from how you (or others) do that in the modules you use might be very useful to detect problems early... a good reason to teach something new to your muscle memory! Cheers, Flavio.
On Sat, Jan 22, 2011 at 2:08 AM, Brian E. Lozier <brian@massassi.com> wrote:
As a perl veteran I am used to using the built-in "warn" function to write to STDERR. Under mod_perl/Apache this prints to the web server's error log. Using my dancer app like this:
plackup -L Shotgun app.pl
If I have a "warn" anywhere in my app, I get an error message:
Error trace
status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.2/Plack/Middleware/StackTrace.pm line 27
However, if I print STDERR "msg"; that works. My question is: what happened to warn? Can it be fixed so that it writes to STDERR instead of triggering an error message?
I know about the "warning" function but it's really hard to change 10 years of muscle memory!
Thanks, Brian _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Hi, there is a bug in Dancer::Route that seems to be triggered only when plackup's Shotgun is active (don't ask me why, there's surely a good reason). There is pull request https://github.com/sukria/Dancer/pull/264 to solve it, if the dev team accepts it you'll find the problem solved at the next release. In the meantime, if you feel like changing the code by yourself, you can apply the patch by yourself: it's a matter of changing one single word. Of course you'll get the error about "warn" when you run the application in the development environment, but this is the expected behaviour as discussed. Cheers, Flavio. On Sun, Jan 23, 2011 at 9:08 AM, Brian E. Lozier <brian@massassi.com> wrote:
$VERSION = '1.2003';
Looks like I'm using 1.2003.
Thanks for your detailed reply, I appreciate it.
On Sat, Jan 22, 2011 at 12:53 PM, Flavio Poletti <polettix@gmail.com> wrote:
Hi, there are different topics involved here. The first one regards the version of Dancer you're running. I tried to start a sample application with "dancer -a Whatever" and added a warn call in the only route handler, but did not get your error. I ran my example with Dancer 1.2002 and the result was the error I expected, which leads us to the following point. The second topic deals with warnings promoted to fatal errors. This is triggered by the "warnings" setting, whose documentation is in Dancer::Config. This setting is enabled by default in the "development" environment, so you should turn this off to get rid of the errors. From what I understood, this is meant to be a useful feature to ensure that you don't get warnings from modules, etc. which you might want to catch as soon as you're in the development process. About your muscle memory, if you want to use "warn" instead of "warning" I think that your best option is to propose a patch which I suppose could be developed along the following lines: * read how to contribute to the project in https://github.com/sukria/Dancer/blob/devel/lib/Dancer/Development.pod * add a configuration option "warn_as_warning" in lib/Dancer/Config.pm * use this configuration option in lib/Dancer/Route.pm subroutine "execute" like this: # ------------------------------------- sub execute { my ($self) = @_;
- if (Dancer::Config::setting('warnings')) { + if (Dancer::Config::setting('warn_as_warning')) { + local $SIG{__WARN__} = \&Dancer::Logger::warning; + return $self->code->(); + } + elsif (Dancer::Config::setting('warnings')) { my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; my $content = $self->code->(); # ------------------------------------- * write tests Anyway, separating how you send warnings in your web application from how you (or others) do that in the modules you use might be very useful to detect problems early... a good reason to teach something new to your muscle memory! Cheers, Flavio.
On Sat, Jan 22, 2011 at 2:08 AM, Brian E. Lozier <brian@massassi.com> wrote:
As a perl veteran I am used to using the built-in "warn" function to write to STDERR. Under mod_perl/Apache this prints to the web server's error log. Using my dancer app like this:
plackup -L Shotgun app.pl
If I have a "warn" anywhere in my app, I get an error message:
Error trace
status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.2/Plack/Middleware/StackTrace.pm line 27
However, if I print STDERR "msg"; that works. My question is: what happened to warn? Can it be fixed so that it writes to STDERR instead of triggering an error message?
I know about the "warning" function but it's really hard to change 10 years of muscle memory!
Thanks, Brian _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
participants (4)
-
Brian E. Lozier -
Fayland Lam -
Flavio Poletti -
sawyer x