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

IRC log for #mojo, 2017-08-19

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

All times shown according to UTC.

Time Nick Message
00:12 marcm joined #mojo
01:14 dt123 joined #mojo
01:16 zerah joined #mojo
02:41 noganex_ joined #mojo
03:29 haarg Grinnz: yeah, i don't think anyone has seriously used the Module::Runtime thing
03:29 haarg and i don't think it belongs in that module
03:29 haarg was just trying to give other examples
04:04 dboehmer joined #mojo
05:41 sh14 joined #mojo
06:37 sh14 joined #mojo
06:54 Vandal joined #mojo
07:50 petru joined #mojo
08:05 dod joined #mojo
08:08 Lee[home] joined #mojo
08:11 dod joined #mojo
09:27 pink_mist http://idlewords.com/talks/website_obesity.htm fun article
10:05 karjala_ joined #mojo
11:14 * CandyAngel is going to try 2-space indents for a project
12:01 karjala_ joined #mojo
12:06 bryan joined #mojo
12:29 mariusz joined #mojo
12:40 * sri doesn't like the defenders :/
12:41 sri the bad guys are soooo weak
12:41 sri and boring
12:42 dod joined #mojo
12:44 sri kingpin and purple man were great antagonists, the hand and elektra have no personality whatsoever
12:54 haarg i haven't watched it yet but that was my concern
12:54 haarg the hand was boring in daredevil and was one of the reasons iron fist was awful
12:55 sri yea
12:58 sri bad antagonists is what made luke cage suck too
13:00 genio I'm continuing to watch in hopes that this season will _finally_ end the hand as they're just plain boring
13:00 genio but once they're gone, no more reason for the iron fist. so, that probably won't happen
13:16 stryx` joined #mojo
13:49 fitnerd joined #mojo
13:51 dod joined #mojo
14:14 karjala_ joined #mojo
14:34 dt123 joined #mojo
14:43 petru joined #mojo
15:06 CandyAngel Hm.. can you pass literal SQL for SQL::Abstract to use in the "column" bit of WHERE?
15:06 CandyAngel ->where({'SHA1(column)', $sha1}) thinks "SHA1(column)" is a column name, so it quotes it
15:07 * CandyAngel is this close to just unsetting quote_char :P
15:07 pink_mist I'm not really familiar with it, but
15:07 pink_mist I think I heard something that if you want literal SQL to be sent, you can often use a scalar ref
15:08 CandyAngel I think that only works for the right-side, if I try it, it says unknown column about SCALAR(..)
15:09 pink_mist ah
15:11 ChmEarl joined #mojo
15:11 CandyAngel yay, I got it!
15:12 CandyAngel You have to do.. ->where({ -and => [ col1 => $value, \['SHA1(col2)' => $value2]]})
15:15 CandyAngel Well, maybe you don't have to, but that is working for me :)
15:16 pink_mist :P
15:22 tchaves joined #mojo
15:22 CandyAngel basically, this change broke my existing code: https://github.com/jhthorsen/mojo-mysql/commit/833ab3c2e8aca733f527ecd15395803f4bd3aa52
15:22 CandyAngel Which is fine, because my code wasn't correct in the first place :P
15:41 batman glad i don't have to change anything :)
15:49 karjala_ joined #mojo
16:30 Lee[home] joined #mojo
16:38 disputin joined #mojo
16:43 sh14 joined #mojo
16:55 castaway joined #mojo
17:06 dod joined #mojo
17:47 CandyAngel ^_^ and you get a thanks for improving my code :P
18:58 petru joined #mojo
19:46 mishanti1 So am I properly dumb for wanting to use Test::Mojo when establishing tests for non-mojo projects? Anyone else doing this?
19:48 preaction Test::Mojo can test any webapp, sure
19:48 pink_mist can it?
19:48 preaction jberger even made a blog post about it iirc with the mojolicious plack adapter to mount any plack app as a mojolicious app
19:49 pink_mist well then it's a Mojolicious webapp :P
19:49 preaction only while you're testing it, at least
19:49 mishanti1 I figured it could, but have not yet testet. But I have a slew of old php-apps that need tests before work being done on them, plus some grandfather-perl stuff using mod_perl in Apache.
19:49 mishanti1 *shudders*
19:49 preaction Test::Mojo can test live webapps too, yes
20:34 karjala_ joined #mojo
21:24 mib_605a32 joined #mojo
21:50 CandyAngel Can I do a depth-first traversal on Mojo::DOM and "escape" HTML tags that aren't whitelisted?
21:56 CandyAngel I can see how to do the traversal (using child_nodes) but I'm not seeing a way of just escaping the tag..
21:58 preaction just skip it if it's not one you want to traverse down
22:00 CandyAngel I want to make "<p><b>text</b></p>" into "<p>&lt;b&gt;text&lt;b&gt;</p>" (because the p is an allowed tag, but the b is not
22:02 CandyAngel Maybe someone has already made a module for this.. it's a pretty common thing to do, though I think other sites just replace the non-permitted tags with their text :/
22:02 CandyAngel (so it would be "<p>text</p>"
22:02 CandyAngel I swear I close my parentheses when I code
22:10 pink_mist https://www.xkcd.com/859/
22:10 CandyAngel Actually, I have a sneaky suspicion that doing it this way is inviting some kind of security bug
22:40 PopeFelix joined #mojo
23:01 leffe joined #mojo
23:02 leffe Hi folks!
23:02 leffe I have another question.
23:02 leffe I'm developing a server for an embedded system.
23:03 leffe The server configures the system and commits changes.
23:04 leffe I need to log things that happens, and keep those logs for latter inspection if needed
23:04 leffe Well, what I need is a robust logging service. I need to rotate logs in production.
23:05 leffe I'll also would need to change logging when in test mode, to STDERR for example.
23:05 leffe I would like to just call
23:05 leffe info 'bla bla bla something interesting happened'
23:05 leffe error 'bla bla bla'
23:06 leffe in my code, model code.
23:06 leffe is there any way to just use a module, let's say Mojo::Log qw(debug info error fatal)
23:07 leffe and that this module writes to STDERR or files, rotating files depending on the enviroment?
23:07 leffe Thans.
23:14 CandyAngel That's pretty much what Mojo::Log does (without the imports)
23:15 CandyAngel But you could make the imports a la Mojolicious::Lite, I'd imagine
23:16 leffe Hi
23:16 leffe It rotates logs?
23:16 leffe Does it have configuration files?
23:18 leffe What I would like to have it's something like Log4x.
23:18 CandyAngel No, it is agnostic to where it outputs it, so you need something like logrotate to rotate the logs
23:18 purl okay, CandyAngel.
23:18 CandyAngel And not sure what you mean by "configuration files" in that sense
23:22 leffe Ok. I developed many years in java. In this world you use Log4j. with log4j you have configuration files for logging, where you specify the format, the output (files, db, network ..) and the enviroment ...
23:22 leffe so when you are in production every thing gets logged to files for example
23:22 leffe when you are testing log outputs to STDERR for example
23:22 CandyAngel Mhm, you can do the same in Mojolicious, it's just not "part of" Mojo::Log
23:22 CandyAngel So you would do like..
23:23 preaction or use Log::Log4perl
23:23 CandyAngel Create a Mojo::Log object and set where you want to output it from a configuration file (Mojolicious has mode-specific configuration files)
23:24 CandyAngel where you want it to output to*
23:24 leffe Really? Where is it documented ?
23:26 CandyAngel Mojo::Log?
23:26 leffe :)
23:26 CandyAngel http://mojolicious.org/perldoc/Mojo/Log#path
23:27 leffe path but not configuration file, to rotate logs, i would need logrotate daemon, right?
23:27 CandyAngel And mode-specific configuration is mentioned in the Description: http://mojolicious.org/perldoc/Mojolicious/Plugin/Config
23:28 CandyAngel or something like that, yeah
23:28 preaction or use Log::Log4perl
23:28 leffe Ok, great.
23:28 leffe Another question
23:29 leffe If I want to share the logging infrastructure between layers ... should I have a global variable for Mojo::Log ?
23:30 preaction or use Log::Log4perl...
23:31 CandyAngel In Mojolicious, you access it through the application object, which is passed.. everywhere?
23:31 CandyAngel $app->log->debug('Log::Log4perl') :P
23:31 CandyAngel Or $self->app->log..
23:32 leffe Do you recomend Log::Log4perl ? Nowadays what I have done is to declare 'abstract methods' in Model Classes, that is sub info; sub error ...
23:33 leffe so the bussines methods call info( 'bla bla' ) when needed
23:33 CandyAngel If you have to listen to me or preaction, preaction is a much safer bet :)
23:33 CandyAngel (and I don't use Log::Log4perl)
23:33 preaction you want log4j, then use log4perl
23:34 leffe no no
23:34 preaction pipe Mojo::Log to log4perl by using Mojo::Log's "message" event
23:34 leffe I do not want to invent the weel
23:34 leffe wheel
23:34 preaction log4perl already exists!
23:35 leffe What I do in tests is override info methods to *Model::info = sub { say shift }
23:35 CandyAngel I think preaction is saying if you are happy with how log4j works, log4perl will give you the same
23:35 leffe and in production to *Model::info = sub {log->info( shift ) }
23:35 preaction that sounds terribly inefficient, developer-time-wise, and easy to get wrong
23:35 leffe ok
23:36 leffe how would you do this?
23:36 preaction do what? what you just said?
23:36 leffe I want to mock log in test enviroment, so it just outputs result, and even beter I can test the output too
23:36 preaction or how would i use log4perl in Mojolicious?
23:37 CandyAngel app->log->on(message => sub { .. send to log4perl .. }) ?
23:37 CandyAngel http://mojolicious.org/perldoc/Mojo/Log#message
23:37 preaction if you're using Mojo::Log, i would look at $app->log->history
23:37 preaction CandyAngel: yes
23:38 preaction but you don't need to mock Mojo::Log to test log output, just look at the history (and perhaps close the filehandles its using)
23:38 preaction you could also test the log by subscribing to the "message" event, but the history is a lot easier
23:39 leffe mmm
23:39 CandyAngel As in, send a log message, then check the history to see if it is there?
23:39 preaction and if you want to just shove everything from Mojolicious to Log::Log4perl, then you can do similar things but using Log::Log4perl's way of doing it
23:39 preaction CandyAngel: yes
23:39 CandyAngel Yeah, that sounds much easier to test
23:39 leffe ok
23:39 preaction no mucking about with symbol tables
23:39 leffe so i would do something like throws_ok { ....}
23:40 leffe and     is log->history ....
23:40 leffe right?
23:40 CandyAngel Doesn't history log the formatted message though?
23:41 CandyAngel I can't remember how it worked now, even though I implemented it in my game engine :P
23:41 preaction no, history logs an array of [ level => timestamp => message ]
23:41 leffe Ok, to sum up
23:41 leffe use mojolicius log
23:41 CandyAngel Ah yeah, so it does :)
23:41 leffe do not mock just check history
23:41 * CandyAngel just looked at the code
23:42 leffe and how do pass the log object to all the Model classes. In constructors? Injecting it somehow? gobal variable?
23:43 preaction like I said, use Log::Log4perl if that's what you want
23:44 CandyAngel I thought changes should be done in the Controller layer..?
23:45 CandyAngel That was probably poorly worded
23:45 preaction once you start getting out of the mojolicious space (out of the controllers), you have to have loggers. if the objects you're using aren't controlled somehow by the mojoicious code, you're not going to be able to pass them the right Mojo::Log instance
23:45 leffe Well, thank you for the advice. I do not want to use anything in particular, I haven't used perl to do a real 'critical app' and I was wondering how was the best way to do it.
23:46 preaction other loggers like Log::Log4perl and Log::Any have their global parts and their local parts. you configure their output once (the global part) and then any class that needs it uses the local part to write to the global log
23:47 leffe The objects I would be using just manage persistence in an xml database. they work syncronously
23:47 leffe I can share the log infrastructure if i want.
23:52 leffe Thanks guys.
23:54 leffe Another question. How would you share a variable to all helpers? registering it as a helper to?
23:58 CandyAngel What sort of variable?

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