The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2018-02-07

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:11 nohuhu joined #mojo
00:12 nohuhu Is there a way to assign a namespace to a route without affecting other routes?
00:13 nohuhu Mojolicious::Routes->to() is not side effect free
00:14 klapperl joined #mojo
00:14 nohuhu Looking at the source I don't think it's possible but maybe I'm misreading something
00:15 Grinnz the namespace only applies to that route and its subroutes
00:15 Grinnz if you assign it in ->to
00:15 nohuhu The idea is to auto-generate routes for CRUD operations, and so far I don't see how to associate a route with particular package/action combo without jumping through flaming hoops
00:16 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Routing#Namespaces
00:16 nohuhu Grinnz: Right, that's what I'm reading. Somehow it affects the parent route as well.
00:17 Grinnz then you're doing something different
00:17 nohuhu Wait a sec, let me find a paster
00:20 nohuhu Grinnz: https://pastebin.com/EwxP7Cum
00:20 Repaster Repasted text from nohuhu: https://perl.bot/p/bad2a2
00:21 nohuhu Setting namespace to '' affects the parent route and Login controller is not resolved anymore
00:21 nohuhu Controller "Login" does not exist
00:22 nohuhu I can't explain that except with to() method having side effects
00:24 nohuhu Trying to call $route->to(controller => 'Fully::Qualified::Package', action => 'foo') doesn't work either, the package name is prefixed with a namespace
00:25 nohuhu Since the namespace is already present in the fully qualified package name, it gets duplicated and package can't be found
00:25 Grinnz i'm not really versed enough in the routing but setting namespace to '' doesn't seem very supported
00:25 nohuhu It certainly looks that way
00:25 Grinnz not sure what you'd even expect that to do
00:26 nohuhu Not being prefixed with a namespace?
00:26 nohuhu I already have the class name, there's no need to munge it
00:26 nohuhu But I don't see a way to let the router know that
00:26 Grinnz the router requires a namespace
00:27 nohuhu I thought a router's job is to map requests to the code that can handle them
00:27 Grinnz i'm just telling you how it works
00:28 nohuhu Namespace might be a nifty concept when writing routes manually but it feels really awkward for generated code
00:28 Grinnz hmm actually namespace => '' should work https://metacpan.org/source/SRI/Mojolicious-7.63/lib/Mojolicious/Routes.pm#L110
00:28 Grinnz but i don't think it's documented
00:28 Grinnz really? namespaces would make generated code way easier i would think
00:29 nohuhu I don't see a need for a namespace if I already have a fully qualified package name
00:29 nohuhu Also the problem that I've bumped into is not in empty string namespace not being supported, it's in empty string namespace being applied to the parent route
00:30 Grinnz ah, namespace => '' will only work if you profile controller => something
00:30 Grinnz provide*
00:30 Grinnz yeah, no idea how that could happen
00:31 nohuhu Ha, this worked
00:32 nohuhu So $route->to(namespace => '', controller => 'Fully::Qualified::Package', action => 'sub_name')
00:32 Grinnz as opposed to?
00:33 pink_mist probably $route->to(namespace => '', action => 'Fully::Qualified::Package::sub_name'); ?
00:33 Grinnz actions are function names only
00:33 pink_mist are you saying that's not a function name?
00:34 Grinnz the part you pass to ->can
00:36 Grinnz since that's what it does https://metacpan.org/source/SRI/Mojolicious-7.63/lib/Mojolicious/Routes.pm#L164
00:43 nohuhu Is there a default helper for the current_route with arguments?
00:44 nohuhu Not sure why current_route only returns the route name, what's the point of that
00:44 Grinnz to get the name of the current route :P
00:44 Grinnz i think url_with should work
00:45 Grinnz i mean, are you trying to get the request url or the things you passed to the router? cause the latter is all in the stash
00:46 nohuhu I need a way to encode current route in a template, so say if an update operation fails the controller would know what page to render to kinda "go back"
00:47 Grinnz that sounds like you want the url then
00:47 nohuhu Yep, but current_route returns only the name.
00:48 nohuhu It's kind of awkward this way, the name hints to the full route contents
00:48 Grinnz the request url is in $c->req->url
00:48 Grinnz or you can construct a url based on route name with url_for or url_with
00:49 nohuhu I was looking for a canonical way of doing that, and current_route looked like it
00:49 Grinnz current_route is the canonical way to get the current route name sure...
00:49 nohuhu But not worked like it, unfortunately
00:50 Grinnz this is what i've used current_route for https://github.com/Grinnz/cpan-meta-browser/blob/master/templates/layouts/main.html.ep#L16-L20
00:51 nohuhu Huh, Vue
00:54 Grinnz i blame jberger for that (it's actually really nice)
00:55 nohuhu It surely gets quite a bit of hype lately, I haven't looked into it yet
00:57 nohuhu But the markup looks like HTML + Bootstrap on steroids, or something
01:01 Grinnz it is HTML5 + bootstrap, yes
01:01 nohuhu Sorry I meant Vue itself
01:02 Grinnz oh
01:02 Grinnz not sure what that has to do with bootstrap
01:02 Grinnz it's usually v-something="some javascript stuff"
01:02 nohuhu Nothing much, except markup looks rather like HTML enhancement
01:05 nohuhu Looks funny, maybe I should try that as well
01:05 nohuhu This old way of doing web apps on server side gets old pretty quick
01:06 Grinnz when i first started playing with knockout it revolutionized how i did javascript, vue just makes it simpler than that i think
01:07 nohuhu Possibru, I've never tried knockout so can't compare
01:07 nohuhu But my $work for the last 5 years has been maintaining one of the oldest and largest JavaScript frameworks out there, and it gets under your skin after a while
01:08 nohuhu Hard to get away from the way of thinking it imposes
01:08 Grinnz heh
01:09 aborazmeh joined #mojo
01:09 Grinnz i mostly just leverage javascript so that i never have to write another HTML-posted form because i hate everything about how that works
01:09 Grinnz i have to keep myself from overusing it past that
01:10 nohuhu Forms are not a big deal honestly, there are things much more hairy
01:10 Grinnz the interaction of forms and cookies and http methods is super ugly
01:10 nohuhu But there's a big disconnect between what raw HTML was designed to do, and what people are expecting from web applications these days
01:10 Grinnz if you just post it through javascript you dont have any of those problems
01:10 nohuhu That's what you think
01:11 Grinnz well, if you do it right :P
01:12 nohuhu I personally don't like HTTP all that much. Not the most sanely designed protocol out there.
01:12 Grinnz it's definitely got its cruft
01:12 Grinnz that's what HTTP/2 is going to fix though right???
01:13 nohuhu My preferred way of communicating with server side would be some kind of RPC, but that requires some effort on the client side as well as on the server
01:13 jabberwok like the East German "Trabant" automobile: It doesn't have to be good, if you make enough of them!
01:13 nohuhu Decent frameworks will give you all that out of the box, but there are reasons why I can't use a decent framework for this project ;(
01:14 nohuhu I've actually seen a live Trabant.
01:14 jabberwok suuuure Grinnz
01:14 nohuhu Well, moving.
01:14 jabberwok downhill ?
01:15 nohuhu jabberwok: Miraculously, it was driving under its own power in the street.
01:15 jabberwok !!
01:15 nohuhu I'm not 100% sure it was all original but what do you expect of a plywood box with a motorcycle engine popped in
01:18 nohuhu Speaking of funny looking vehicles, there's a guy in our town who drives 1958 BMW Isetta
01:19 nohuhu Not sure if that one made of plywood but it sure is a funny looking three wheel car
01:20 Grinnz There's a guy around here that rides a penny farthing and he uses a stepstool to get on and off it
01:22 nohuhu I think that's basically the only way to get on it
01:25 nohuhu Ohkay, now the auto-generated routes started working but stopped stopping at authentication fail
01:25 nohuhu *sigh*
01:29 nohuhu Ah my bad, forgot to return falsy value from the controller that handles auth
01:29 Grinnz return values very important in under-actions
01:30 Grinnz made that mistake a few times
01:30 Grinnz gotta make sure it's always explicitly returning something
01:30 nohuhu Yup. But that stuff was mentioned in the docs, so all good.
01:32 nohuhu Although seeing "return undef" in the code feels a bit strange. Critic would probably dislike that.
01:32 Grinnz only if you're using nonsense policies
01:33 Grinnz return; is bad in any case except a function that will only be called in void context
01:33 nohuhu In the case of that doc snippet there's no particular reason to return undef. Return 0 or return !1 would work just the same, and feel more mainstream.
01:33 Grinnz return undef is pretty mainstream to me, but sure
01:34 Grinnz 0 and 1 are also common
01:34 purl okay, Grinnz.
01:34 nohuhu I only use that when I need to explicitly return undef value
01:34 nohuhu Otherwise I'm not aware of any bad side effects of no-argument return
01:35 nohuhu Well, practically speaking
01:35 nohuhu Hair splitting either way
01:35 Grinnz it's context-ambiguous and leads to bugs
01:35 Grinnz it broke bugzilla
01:35 Grinnz well not that specifically but a similar context sensitive return
01:35 nohuhu I ain't writing no bugzilla so nothing to worry about
01:36 Grinnz i would still worry about it
01:36 Grinnz https://metacpan.org/pod/Perl::Critic::Policy::Freenode::EmptyReturn
01:37 nicomen I think it's hard to side with any of return; vs return undef; but it's easy to side with no return vs. always return ;)
01:37 nohuhu Grinnz: I'm aware of context sensitivity of no-argument return, but I would consider that a feature rather
01:37 Grinnz it's not a feature once you use it wrong
01:37 nohuhu That is true about a lot of features.
01:38 Grinnz foo($first, $second, function_with_bare_return(), $fourth); # boom, $fourth randomly ends up in third spot
01:38 nohuhu That's why I don't do that
01:38 nicomen don't chain methods in methods calls, solved
01:38 Grinnz riiiight
01:39 nicomen the other way around is worse
01:39 Grinnz the actual solution is to write functions intended for a specific context, like every function in mojolicious
01:39 nicomen my @foo = method(); if (@foo) { … only do this if method succeeds }; # break it with return undef;
01:40 nohuhu nicomen++
01:40 Grinnz obviously you wouldn't return undef from a function intended for list context use
01:40 nohuhu I thought your point was in functions used out of their intended context?
01:41 nicomen so we should just always use Contextual::Return? ;D
01:41 Grinnz yes, and you can accidentally call a scalar-intended function in list context very easily
01:41 nicomen I see many people "solve" this by returning array refs always
01:41 Grinnz thats also a good option
01:41 Grinnz i mean, instead of list returns
01:41 Grinnz not *always*, that would be silly
01:42 nohuhu Grinnz: -- Doctor, it hurts a lot when I do this! -- Well, don't do that then.
01:42 Grinnz i don't need to prove this to you, it's an extremely common pitfall that's caused massive vulnerabilities one of which was the subject of that horrible perl jam talk, and this is the way to avoid it
01:43 nohuhu Grinnz: Consider me duly warned, and your mission fulfilled. Thank you.
01:43 nicomen my $hash = { foo => foo(), bar => bar() } is fun…
01:43 Grinnz that's the usual mechanism, yeah
01:44 nicomen if I try to be clever like that I tend to do foo => ( foo() // 'safe-fallback' ), though
01:44 maschine joined #mojo
01:45 nohuhu I almost always assign function results to variables in my code, simply because that makes it so much easier to step through and see what happens in the debugger
01:45 Grinnz because of the way the syntax works, it seems to be unintuitive that hash construction and function parameters are list context; so people call functions to get a scalar in them, but if the functions have different behavior in list context they change the behavior of the calling code
01:46 nicomen yeah I prefer using intermediate variables too
01:46 Grinnz and that's why CGI.pm added multi_param and warns when you call param in list context, and why mojolicious param was refactored into param and every_param (along with several similar methods)
02:00 nicomen one can argue that if you are writing something that behaves differently depending on context, you should explitly state the context
02:02 Grinnz its definitely an issue that can be mitigated on both sides, but the issue occurs when the function user and the function writer are not the same
02:03 Grinnz well i'm sure it can occur when they are the same too, but i mean more that they're not closely related :P
02:10 dikim joined #mojo
02:11 nicomen I think in hindsight, context is really cool, but so many things would be easier without, list-flattening is ok, I didn't even know perl was context sensitive till like 10 years after I tried perl the first time
02:11 nicomen 8 years, but still
02:11 Grinnz yeah, and a lot of the context sensitive builtins are more unfortunate than anything
02:12 nicomen which was really sad, as I believe context is a pilar in perl
02:12 Grinnz when you have to read the docs every time you use m// and s/// to see what they do in each context with and without /g etc...
02:12 nicomen at least somethiing the first chapter of any perl book should mention
03:07 zivester joined #mojo
03:21 dikim joined #mojo
03:58 Seth joined #mojo
04:09 maschine joined #mojo
05:04 dboehmer joined #mojo
05:10 inokenty-w joined #mojo
06:48 dod joined #mojo
06:55 dod joined #mojo
07:16 polettix joined #mojo
07:29 Vandal joined #mojo
07:30 dod joined #mojo
07:46 ashimema joined #mojo
07:48 AndrewIsh joined #mojo
08:14 McA joined #mojo
08:24 trone joined #mojo
08:47 karjala_ joined #mojo
08:53 berov joined #mojo
08:53 Edward joined #mojo
08:55 ashimema joined #mojo
09:21 mtths joined #mojo
09:24 ashimema joined #mojo
09:43 sri argh, i made a small mistake with the systemd patch yesterday
09:52 good_news_everyon joined #mojo
09:52 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vAfZ2
09:52 good_news_everyon mojo/master a232820 Sebastian Riedel: short log messages can span multiple lines, and each line needs a magic number prefix
09:52 good_news_everyon left #mojo
09:55 sri this is what we now have https://i.imgur.com/RNhWS4Q.png
10:17 good_news_everyon joined #mojo
10:17 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vAfC3
10:17 good_news_everyon mojo/master 524cfb8 Sebastian Riedel: bump version
10:17 good_news_everyon left #mojo
10:17 good_news_everyon joined #mojo
10:17 good_news_everyon [mojo] kraih tagged v7.64 at 28f69e7: https://git.io/vAfCs
10:17 good_news_everyon left #mojo
10:17 sri lets do daily releases again, like in the old days :D
10:33 CandyAngel Obviously log files should just be JSON. Not as stupid as binary, but more organised than text \o/
10:33 CandyAngel (not a serious suggestion)
10:34 haarg streaming xml
10:55 * sri is trying to understand how journald rotates files
10:56 CandyAngel Either at 5400 or 7200 RPM
10:57 sri http://instantrimshot.com/index.php?sound=rimshot&play=true
11:30 tchaves joined #mojo
12:10 tcohen joined #mojo
12:29 gregf_ joined #mojo
12:55 dod joined #mojo
13:00 dod joined #mojo
13:03 tcohen joined #mojo
13:05 dantti_laptop joined #mojo
13:21 karjala_ joined #mojo
13:41 zivester joined #mojo
14:18 gizmomathboy joined #mojo
14:35 jabberwok joined #mojo
15:08 karjala_ joined #mojo
15:09 gryphon joined #mojo
15:16 jberger Grinnz: I'll take that blame, I continue to be happy with Vue
15:47 genio I tried to like Vue/React...
15:47 genio $work has gone the way of Polymer instead and I admit that I like it better
15:53 ChmEarl joined #mojo
15:53 dod joined #mojo
15:54 karjala_ I also like vue
15:54 dod joined #mojo
15:54 jberger genio haven't tried Polymer
15:54 jberger what's the selling point?
15:54 purl the selling point is that it provides *in-core* IPv6
15:54 jberger purl: that sounds nice but ... scram
15:54 purl jberger: huh?
15:56 genio web components
15:56 purl web components are https://plus.google.com/u/0/103330502635338602217/posts
15:57 karjala_ i think those are planned in vue at some point
15:57 karjala_ in future
16:08 maschine joined #mojo
16:26 montezuma joined #mojo
16:51 Peppard joined #mojo
17:13 ghenry joined #mojo
17:14 hesco1 Doing a $t->get_ok()->status(200)->json_is(); I get 'Structures begin differing at:'.  Question is: how do I get the structure I 'got' to dump it and examine it?
17:14 Grinnz use Mojo::Util 'dumper'; diag dumper $t->tx->res->json;
17:15 hesco1 thanks Grinnz!
17:16 sri $t->get_ok()->or(sub { diag dumper $t->tx->res->json })
17:17 sri s/get_ok/json_is/
17:18 hesco1 Thanks mate, quite illuminating.  Back to the SUT!, and thanks @sri, nice enhancement.
17:18 * sri wonders if tempire has seen the example yet :,( http://mojolicious.org/perldoc/Mojolicious/Guides/Testing#Extending-Test::Mojo
17:19 Grinnz ooh, didnt know about ->or
17:19 jamesaxl joined #mojo
17:27 jberger I'd love to make Test::Mojo::Role::Debug just a little bit nicer
17:28 jberger like, maybe it could detect content type and use dom or json depending on what the response was
17:28 sri first finish the other things you've promised to make nicer! :p
17:28 jberger there's a reason I haven't done it of course :-P
17:28 jberger I don't even remember what I've promised at this point anymore :s
17:30 jberger if I find a chunk of time, the Mojo::Chrome is the top of my list I think
17:31 sri the trump strategy to promises i see :)
17:32 jberger assuming he really doesn't remember things, then yeah :D
17:34 Grinnz hahah
17:34 pink_mist he has one of the greatest memories of all time!
17:34 pink_mist or so he will tell you
17:34 Grinnz he's a very stable genius!
17:48 maschine if I have more jobs in the queue than my minion worker is set to run at a time (default is 4), does it fork another worker automatically?
17:50 Grinnz no
17:51 nicomen [dumper] why not just use diag explain $foo ?
17:51 maschine reading here: http://mojolicious.org/perldoc/Minion/Command/minion/worker
17:51 maschine I'm missing where to set up additional workers
17:51 dod joined #mojo
17:52 maschine right now I only ever have 1-2 jobs at a time, but soon I will have many more. :)
17:52 sri you start them yourself
17:52 maschine So basically just run the command twice to start 2 workers?
17:52 sri but it's a queue, you're supposed to have more jobs than you can process at a time
17:53 maschine yes I understand that part
17:54 maschine to answer my own question - yes :)
17:55 Grinnz normally you'd just start it once with a higher count of jobs to run
17:55 Grinnz the reason to start more workers is usually to spread them across servers
17:56 sri at work we have a maintenance task that results in 30k low priority jobs that slowly run for a day, while at the same time normal jobs run with high priority to skip to the front of the queue
17:56 sri works flawless
17:56 sri think we're running one worker with 12 jobs
17:57 sri and what Grinnz said
17:58 maschine makes sense - so if you had 2 workers and 10 jobs each, they would get 10 jobs from the queue at a time right?
17:59 sri each
18:00 sri the limiting factor you have to consider is usually available memory
18:00 sri at least for the data processing tasks i usually deal with
18:02 sri cpu is mostly kinda meh... operating systems can handle that, but running out of memory because you randomly got 12 heavy jobs at the same time sucks
18:03 sri the minion fork for every job model has definitely proven itself, i can't imagine dealing with job processes running forever
18:03 maschine yeah I can see that - I'll have to test it when I start running more jobs
18:04 sri worst problem i had was when the server ran out of memory and killed the manager process before the jobs
18:05 sri because for oomkiller they have the same weight by default
18:06 sri actually wonder if the code we use to mitigate that at work could be a role... hmmm
18:07 Grinnz https://memegenerator.net/img/instances/60794789/roles-roles-everywhere.jpg
18:07 sri $worker->with_role('+Linux::MemoryLimit')
18:07 sri should work
18:08 sri a setting with the limit in status, and wrapping a method that can register a few events
18:08 sri could even have remote control with the memory limit
18:09 sri oh, right, it can just wrap the run method
18:11 nohuhu joined #mojo
18:11 sri although, i guess it's better as a Minion role
18:11 sri wrapping the worker method
18:30 maschine joined #mojo
18:30 maschine joined #mojo
18:33 hesco1 using Test::Mojo, after my SUT uses a ->redirect_to(), recalling the same route, so that $route redirects to $route/all, I no longer get my logging, only the final error message, with ->json_is() responding: 'Does not exist'.  How do I see those missing logs so I can sort out what the issue is here?
18:41 Repaster joined #mojo
18:52 Seth joined #mojo
18:54 Seth1 joined #mojo
19:24 hesco1 using $self->app->log, how do I set the logging level, and can it be configured by namespace, like log4perl?
19:24 nohuhu hesco1: I think it should be used with logging level as a method: $self->app->log->debug()
19:26 Grinnz nohuhu: that's the opposite of what he's asking
19:26 Grinnz hesco1: you can set the level attribute, or you can set the env var MOJO_LOG_LEVEL (recommended to have the level apply before startup runs)
19:26 hesco1 nohuhu: yes, that is how I invoke it.  Now I want to ignore my ->debug messages and still see the ->info messages.  And I'd like to watch ->debug in the module which is currently the focus of development, without being bothered by the noise from those areas of the code which are stable.
19:26 nohuhu Grinnz: Could be, my coffee still didn't kick in
19:27 hesco1 coffee?  nice idea!
19:27 Grinnz hesco1: also if it's just whether you want debug logging or not, the level is set to 'info' by default in any mode other than 'development' so you can set MOJO_MODE=production to achieve that
19:27 Grinnz hypnotoad runs in that mode by default, and some other commands have options to set the mode
19:28 Grinnz setting MOJO_LOG_LEVEL is only really if you want finer control
19:28 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Tutorial#Mode
19:31 trone joined #mojo
19:40 hesco1 thanks Grinnz.  Been 3-some years since I was immersed in this framework.  $job required other tools until recently.
19:44 hesco1 These look promising:  https://metacpan.org/pod/MojoX::Log::Log4perl and https://metacpan.org/pod/MojoX::Log::Log4perl::Tiny
19:44 hesco1 and in the mean time, I'll use an environment variable
19:46 Grinnz hesco1: https://metacpan.org/pod/Mojolicious::Plugin::Log::Any supports Log4perl
19:50 karjala_ joined #mojo
19:53 Grinnz i would recommend it over the approach of replacing the Mojo::Log object entirely
19:57 tchaves joined #mojo
19:57 hesco1 thanks, looking at that next.
20:00 spicyjack Grinnz: nifty
20:13 hesco1 Grinnz:  you want this as an issue report on your github project page?
20:13 hesco1 Can't locate object method "parse" via package "Mojo::Home" at $project_home/t/../local/lib/perl5/Log/Log4perl/Config.pm line 616.
20:14 jamesaxl joined #mojo
20:14 hesco1 does a work-around exist?  Or should I test one of the other modules?
20:15 good_news_everyon joined #mojo
20:15 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vAJih
20:15 good_news_everyon mojo/master 55953f0 Sebastian Riedel: add 421 status code
20:15 good_news_everyon left #mojo
20:20 Grinnz hesco1: can you show how you tried to use it?
20:25 hesco1 Grinnz:  https://gist.github.com/hesco/59bb7b6c79eff18ea3cc753575148f77
20:26 Grinnz hesco1: i would guess this is Log4perl misinterpreting the argument you passed. try adding ->to_string after ->child()
20:27 Grinnz i'll update the synopsis example with that as well
20:31 sri interesting http/2 talk if you were thinking of using push https://www.youtube.com/watch?v=wR1gF5Lhcq0
20:32 pink_mist (is push any improvement to websockets?)
20:32 sri he even says the thing for which i got flamed to hell (that http/2 is just a transport protocol for http/1.1)
20:33 sri well, the conclusion is that http/2 push is messed up and super hard to use
20:33 sri it's not comparable to websockets
20:33 sri it pushes stuff into browser caches
20:34 pink_mist oh
20:34 sri (yes, caches... that's the problem, many caches that make things really bad)
20:34 pink_mist that seems quite insane
20:34 sri also interesting point he had was packet loss
20:34 sri that totally messes up http/2
20:35 sri since there's just one tcp connection, you've got head of line blocking at the tcp level
20:36 sri while a browser would use many tcp connections for http/1.1
20:36 sri (not really new information, but funny considering that http/2 was supposed to help mobile devices)
20:37 berov joined #mojo
20:37 pink_mist heh, yeah
20:38 sri also interesting is that if you're running very busy servers you might want to try googles new congestion control algorithm, which seems like magic
20:49 kaare joined #mojo
20:50 Grinnz hesco1: did that work?
20:51 hesco1 Grinnz: yes, that walked me past that last error, to one having to do with the l4p config, which I am still trying to sort out.  Thanks for the lead.
20:51 Grinnz cool. i'm a noob when it comes to log4perl so wouldn't be much help there.
20:55 hesco1 l4p requires that I set up a distinct logger in each namespace so I can route log requests in suitable ways, paying attention to the behavior of the fragile code and ignore the behavior of the stable code.  In this way, debug noise can get converted into logging, but suppressed, except when you actually need it.  Nice theory anyway, when you can make it work.
20:57 Grinnz I generally use Log::Any which has similar ability to route but much more perly setup, IMO
20:58 Grinnz though I think for something super complex, Log4perl is still more powerful
20:58 Grinnz and that's why i gave that plugin so many options :P
21:00 Grinnz for either of those if you're trying to route things, take note "For Log::Any or Log::Log4perl, log messages are dispatched with a category of the application class name, which is Mojolicious::Lite for lite applications."
21:02 Grinnz you can customize it further by using the role and attach_logger method directly
21:15 hesco1 So you have seen L4p work, then?
21:16 hesco1 Now seeing this in my logs:  Can't locate object method "get_logger" via package "Mojo::Log__WITH__Mojo::Log::Role::AttachLogger"
21:17 hesco1 will create an config entry to catch Mojolicious, then, see if that helps.
21:18 Grinnz that, uh... what
21:18 Grinnz isn't possible
21:18 Grinnz also why did everything get html encoded
21:20 pink_mist what version of Mojolicious are you loading in that script? I see you're setting up a special "use lib" before you load Mojolicious, so it might be a different Mojolicious than what the logging plugin got installed for
21:20 pink_mist please make sure it's of a compatible version
21:23 hesco1 my cpanfile says:
21:23 hesco1 requires 'Mojolicious', '7.33';
21:23 hesco1 requires 'Mojolicious::Plugin::Log::Any', '0.004';
21:24 pink_mist you need at least 7.40 for roles
21:24 pink_mist I think
21:24 Grinnz the plugin requires 7.40 anyway
21:24 Grinnz but he was asking what version you have loaded at runtime
21:25 hesco1 7.33 was the latest-&-greatest when I started this project a few weeks ago.  I see 7.64 is now available, will upgrade.
21:26 hesco1 carton reports: Successfully installed Mojolicious-7.64 (upgraded from 7.60)
21:26 hesco1 so I guess something else had upgraded me anyway.
21:27 polettix joined #mojo
21:28 pink_mist and you're sure that's the version getting loaded by your script, considering the use lib line?
21:29 sri 7.33 was june last year
21:30 hesco1 @sri: may have simply copied that line from another project, not sure.
21:32 pink_mist hesco1: you can check by doing: myapp.pl version
21:39 hesco1 my $logger = $self->app->log->get_logger('MyAPI.Controller.AcceptableUsePolicy.signed');
21:40 hesco1 that is how I am trying to use this.
21:40 hesco1 But that blows up, telling me ->get_logger is not supported by my object.
21:41 hesco1 Again, Grinnz, as you say you never use L4p, I wonder the extent to which this path has been tested.
21:42 Grinnz oh, it said get_logger, i misread that
21:42 Grinnz um
21:42 Grinnz why are you calling get_logger on it?
21:43 Grinnz it's a Mojo::Log object
21:44 Grinnz isn't get_logger generally called on Log::Log4perl?
21:48 hesco1 yes, so how is it I would access an object of that class?
21:49 Grinnz i don't understand the question
21:51 hesco1 before I can use a $logger, I have to instantiate one.  Traditionally that is done specific to each namespace.  i.e. the $logger I attempted to instantiate above would be specific to logging calls from the MyAPI::Controller::AcceptableUsePolicy->signed() method.  How would I do this inside of Mojolicious::Plugin::Log::Any?
21:52 hesco1 not inside it, really, but using an object of that class?
21:52 Grinnz you wouldn't; if you want a Log4perl logger then get a Log4perl logger
21:52 Grinnz the purpose of this plugin is to forward *mojo* logging to elsewhere
21:52 Grinnz so basically in addition to your use of Log4perl, mojo logging will also go there
21:52 hesco1 ok, testing the next module.  thank you for that clarification.
21:53 Grinnz i'm not sure what the point of having mojo wrap log4perl would be. it has no concept of this stuff
21:55 Grinnz in other words. you should not try to shove Log4perl logging through app->log
21:55 Grinnz just log direct to Log4perl, it's global
21:56 dikim joined #mojo
21:57 Grinnz if you need the convenience of getting it from the app i would write a helper like: $app->helper(get_logger => sub { Log::Log4perl->get_logger(@_) });
21:57 Grinnz then you could call $c->get_logger etc
21:58 Grinnz er, sub { Log::Log4perl->get_logger($_[1]) }); since there's the invocant
22:06 hesco1 First test of this successful:  https://metacpan.org/pod/MojoX::Log::Log4perl; but I do not see how to namespace the $logger's by method, so may be about to switch back and test your helper idea.
22:19 Grinnz if you want a function that will automatically get the logger for the current package and subroutine, you could do it by defining a sub in the application class: sub get_logger { my $category = (caller(1))[3]; $category =~ s/::/./g; return Log::Log4perl->get_logger($category); }
22:19 Grinnz and then calling $c->app->get_logger;
22:20 Grinnz i wouldn't do that via a helper because then you'd be depending on how mojo autoloads helpers
22:38 marty_ joined #mojo
22:39 marty joined #mojo
22:41 Grinnz deadpool 2 looking to be pretty awesome
22:45 spicyjack the critics are digging Black Panther too
22:45 Grinnz yeah looking forward to that one
22:47 sri me too
22:48 sri deadpool 2 marketing is also on point again
22:51 sri so many marvel movies this year
22:52 sri also spider man, infinity war and venom
22:53 Grinnz infinity war is going to be so ridiculously hyped
22:53 Grinnz but if anyone can deliver
22:55 sri yea, even the bad marvel movies are entertaining
22:55 Grinnz is infinity war gonna be the first movie to have chris pratt, hemsworth, and evans? lol
22:55 sri oh, another ant man movie too this year
22:56 sri ETOOMUCHMARVEL
22:56 Grinnz not enough marvel :P i wish i could watch the current season of agents of shield too, but hulu forces you to watch commercials so fuck that
22:57 sri Grinnz: i still remember when RDJ was the big marvel star
22:57 Grinnz man infinity war is so much more than an ensemble cast at this point
22:57 Grinnz dr strange, spiderman, all the people from guardians of the galaxy
22:58 sri iron man made it all possible
22:58 Grinnz yeah there was nothing else back then
22:58 Grinnz too bad dc didn't do as well off the dark knight movies
22:59 sri wonder woman showed that there is still hope
22:59 Grinnz gotham is also really awesome for a dc series
23:00 sri i wish nolan did more dc movies
23:00 sri dark knight was really something else
23:01 Grinnz yeah it would make sense to go back to what worked
23:01 sri gotham got too cheesy for me
23:02 Grinnz i didn't get that vibe, certainly from the other DC shows though, but i just appreciate them as they are
23:02 Grinnz you gotta approach them like reading a comic book
23:02 sri black lightning is not terrible i heard
23:03 pink_mist heh, I heard it was :P
23:03 sri but i can't stand the super cheesy CW shows normally
23:03 Grinnz is that a new arrowverse show?
23:03 pink_mist no
23:03 pink_mist it's specifically not arrowverse
23:04 Grinnz hmm
23:05 Grinnz looks like you can only stream it from CW so far, meh
23:06 sri it
23:06 sri 's on netflix here
23:06 Grinnz not here heh
23:07 sri that new syfy show is very deadpool
23:07 sri happy
23:09 sri oh, another marvel movie this year, x-men dark phoenix
23:09 Grinnz oh yeah i was wondering when the next xmen would be
23:13 dikim joined #mojo
23:14 Seth joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary