Skip to content

Instantly share code, notes, and snippets.

@lloy0076
Last active April 15, 2023 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloy0076/11af8ba82ce897cd9ec7a267170b83ed to your computer and use it in GitHub Desktop.
Save lloy0076/11af8ba82ce897cd9ec7a267170b83ed to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use feature ':5.10';
use local::lib;
use Carp;
use Data::Dumper;
use Mojolicious::Lite -signatures;
get '/' => sub ($c) {
$c->app->log->debug('f00bar'); # I'm trying to figure out where this would log to.
$c->render(text => "Mode: " . app->mode);
};
get('/foo' => sub ($c) {
$c->render(text => 'Foo Bar');
});
app->start();
sub getDir {
opendir(my $DH, '.') || croak('Unable to open directory.');
my @files = readdir($DH);
return @files;
}
@lloy0076
Copy link
Author

After doing some digging, it's probably going to STDERR.

bless( {
  "color" => undef,
  "events" => {
    "message" => [
      sub { "DUMMY" }
    ]
  },
  "format" => sub { "DUMMY" },
  "handle" => \*::STDERR,
  "history" => [
    [
      "1681576990.14162",
      "trace",
      "[sRFzdhZls5kM]",
      "GET \"/log\""
    ],
    [
      "1681576990.14244",
      "trace",
      "[sRFzdhZls5kM]",
      "Routing to a callback"
    ]
  ],
  "level" => "trace",
  "max_history_size" => 10,
  "short" => undef
}, 'Mojo::Log' )

...is a nice rendition of:

get('/log' => sub ($c) {
  $c->render(text => "<pre>\n" . $c->dumper($c->app->log) . "</pre>");
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment