ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
rcvalle_ has joined #crystal-lang
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
early has joined #crystal-lang
rocx has quit [Ping timeout: 260 seconds]
rocx has joined #crystal-lang
<straight-shoota> `XML.build_fragment {|b| b.text("<foo>") } # => "<foo>\n"`
<straight-shoota> `XML.build_fragment {|b| b.start_element("p"); b.text("<foo>"); b.end_element } # => "<p>&lt;foo&gt;</p>\n"`
<straight-shoota> WTF?
<FromGitter> <Blacksmoke16> isnt that expected?
<FromGitter> <Blacksmoke16> would need CDATA for them not to be escaped
<oprypin> but the first one?
<oprypin> maybe it's just not inside element so it doesn't care
<FromGitter> <Blacksmoke16> maybe it just knows its not within an element
<FromGitter> <Blacksmoke16> yea
<straight-shoota> It shouldn't matter if it's inside an element
<straight-shoota> b.text("<foo>") should always be escaped
<oprypin> straight-shoota: well to be fair in xml there's no such thing as text outside an element
<straight-shoota> can't I have a fragment with only text?
<straight-shoota> not sure
<straight-shoota> in HTML context this is definitely unexpected
<straight-shoota> libxml2 has xmlTextWriterWriteString and xmlTextWriterWriteRaw
<straight-shoota> I'd expect the former to always escape and the latter to never escape
<oprypin> aha ok
<straight-shoota> but for some reason it writes raw if the writer has no nodes yet
_whitelogger has joined #crystal-lang
<FromGitter> <watzon> Funny enough, we were just talking about all this earlier lol
rcvalle_ has quit [Ping timeout: 244 seconds]
hightower4 has quit [Ping timeout: 258 seconds]
<FromGitter> <Blacksmoke16> any thoughts on why adding `# :nodoc:` would still display a `JSON::Any` in the docs?
<FromGitter> <bew> Where is you :nodoc: ?
<FromGitter> <Blacksmoke16> didnt commit it yet
<FromGitter> <Blacksmoke16> but right one the `JSON::Any`
<FromGitter> <bew> Maybe because it already has some documentation?
<FromGitter> <bew> (didn't check but) maybe the doc checker for nodoc checks in the first comment but not on the next ones
<FromGitter> <Blacksmoke16> maybe how im requiring things
<FromGitter> <Blacksmoke16> ill see if i can reproduce with some diff code
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebcac25f8ac2178074678a4]
<FromGitter> <Blacksmoke16> requiring "json" *after* applying the nodoc
chachasmooth has quit [Ping timeout: 240 seconds]
chachasmooth has joined #crystal-lang
<FromGitter> <sam0x17> @straight-shoota was cuz I wrote 300 lines of code not realizing that `[]=` wasn't a thing (because some macros were in progress as well) so did the lazy thing
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
rocx has quit [Ping timeout: 260 seconds]
rcvalle_ has joined #crystal-lang
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
<FromGitter> <galvertez> hey guys i noticed something weird and i can't seem to figure out if it's a documentation issue or... something else? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ since they're both defined more or less the same way - they are both contained w/in the namespace `OpenSSL::SSL::Socket` and both inherit from the abstract class of the same name [https://gitter.im/crystal-lang/crystal?at=5ebce7922cf0da0ad9fff000]
_ht has joined #crystal-lang
<FromGitter> <galvertez> at first i thought "oh, yeah it makes sense, because it inherits from the socket so it includes itself in the namespace so it's valid, but the doc generator wouldn't know that
<FromGitter> <galvertez> but then i couldn't do the same thing w/ `OpenSSL::SSL::Client` - it only works as `OpenSSL::SSL::Socket::Client`
<FromGitter> <galvertez> i guess i don't really care either way, it's just a little confusing because i can't find anywhere in the openssl src that should make `OpenSSL::SSL::Server` work that wouldn't also make `OpenSSL::SSL::Client` work lol
<FromGitter> <galvertez> so maybe somebody who's better at reading code can figure it out
bazaar has quit [Quit: leaving]
bazaar has joined #crystal-lang
DTZUZU has quit [Ping timeout: 260 seconds]
ua has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
ua has joined #crystal-lang
yxhuvud has quit [Remote host closed the connection]
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Max SendQ exceeded]
HumanG33k has joined #crystal-lang
yxhuvud has joined #crystal-lang
<jhass> If not overwritten with the prelude option, Crystal by default requires https://github.com/crystal-lang/crystal/blob/master/src/prelude.cr
<jhass> mmh, but yeah there's nothing in there that should load any openssl stuff
HumanG33k has quit [Remote host closed the connection]
<jhass> oh I overead your require "openssl"
<jhass> yeah that's indeed weird
<jhass> there's no such thing as OpenSSL::SSL::Client
<jhass> there's OpenSSL::SSL::Socket::Client
HumanG33k has joined #crystal-lang
alexherbo22 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo22 is now known as alexherbo2
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo21 is now known as alexherbo2
<raz> ^ anyone? i have a feeling there must be an easy way that i'm missing
DTZUZU has joined #crystal-lang
<raz> oh!
<raz> now that's a keyword i've never used before
<raz> nice, thx!
<raz> ah yep, that looks slightly more familiar. i had mostly avoided #as and completely avoided `alias` so far.
<raz> but now i need this nested hash thing, so that looks like the way to go
<jhass> raz: also https://carc.in/#/r/92mg
<jhass> ah wait I never called it xD
<raz> yep the latter is almost exactly what i need. sweet.
<jhass> yeah nvm the last one, I always forget that restrictions don't cast
<raz> ok, maybe not then. but i'm almost sure i can stitch it together from here :D
<jhass> I meant https://carc.in/#/r/92mh but it doesn't work :D
<raz> yea, just sneakin in .as(MyAlias) should do it i think
<raz> for my case
<jhass> to not forget good ol' of
<raz> of is one of my best friends, never lets me down
<jhass> you can think of alias Foo = Bar as record Foo, value : Bar where crystal implicitly accesses value for you
<jhass> and forwards all method calls
<yxhuvud> at least historically, aliasing generics have been fraught with bugs though. so beware that any issues *may* not be your fault.
<raz> hmm yep. i half-wonder if the compiler could actually figure it out itself w/o an explicit alias
<yxhuvud> perhaps it is fixed now though
<raz> well, that would be my first compiler bug ever. lookin forward to it!
<yxhuvud> That's the spirit!
<raz> will write a ticket of epic proportions and somehow blame it all on the existence of symbols in the end.
<raz> that's the plan at least, will see how it goes
<jhass> most of the alias compiler bugs can be worked around with a simple wrapper struct like above. It's just less convenient
<raz> yup yup, not too worried. in this particular case i could also just write out the two hash variants i want to allow. but good to know about the alias-route for more complicated cases
rocx has joined #crystal-lang
DTZUZU has quit [Ping timeout: 256 seconds]
DTZUZU has joined #crystal-lang
<FromGitter> <Blacksmoke16> @galvertez sure you dont mean https://crystal-lang.org/api/master/OpenSSL/SSL/Context/Client.html
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#6d0d63f (master - XML: improve xpath regarding namespaces (#9288)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/686979066
<DeBot> https://github.com/crystal-lang/crystal/pull/9288 (XML: improve xpath regarding namespaces)
zorp has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
zorp has joined #crystal-lang
<FromGitter> <Uzay-G> What would be the best way, given a `Time` object, to check if the day is today
<FromGitter> <Uzay-G> The whole `Time` class is a bit blurry for me 😄
<FromGitter> <Blacksmoke16> prob like `time_obj.day == Time.utc.day`
<FromGitter> <Uzay-G> oh ok thanks. I will try 👍
<FromGitter> <Blacksmoke16> or `Time.local`, depending on desired functionality
travis-ci has left #crystal-lang [#crystal-lang]
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#7f399f0 (master - Use `_realpath$DARWIN_EXTSN` function in Darwin to fix issue with Catalina (#9296)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/687013380
<DeBot> https://github.com/crystal-lang/crystal/pull/9296 (Fix: realpath on macOS 10.15 (Catalina))
<FromGitter> <Uzay-G> oh ok. I am looking at the granite docs to see how I can run queries like that. Am i correct in thinking that this gets posts from the last 7 days: `Post.where(:created_at, :gt, Time.local - 7.days)`
<FromGitter> <Uzay-G> what does the `:gt` operator do?
<FromGitter> <Blacksmoke16> greater than
<FromGitter> <Uzay-G> oh yeah lol 😄
<FromGitter> <Blacksmoke16> that would get you posts created in last week
<FromGitter> <Blacksmoke16> but id hope you're storing UTC in the db
<FromGitter> <Blacksmoke16> thus `Time.utc` would prob be better here
<FromGitter> <Uzay-G> i'm not sure. I will check how Granite handles its automatic timestamps.
<FromGitter> <Blacksmoke16> 99% sure they're utc
<FromGitter> <Uzay-G> ok thanks. I am going to find a way to get the time object of the current day at time 00:00 and use that to compare
<FromGitter> <Uzay-G> So i can get all posts of the day
<FromGitter> <Blacksmoke16> `Time.utc.at_beginning_of_day` would prob do it
* FromGitter * tenebrousedge has sleepies
<FromGitter> <Uzay-G> thank you so much 😄
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#b977a95 (master - Escape CDATA end sequences (#9230)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/687020468
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9230 (Escape CDATA end sequences)
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
<FromGitter> <xmonader> if i have musl on my ubuntu dist why can't i use that for static linking? why require me to use alpine?
<FromGitter> <Blacksmoke16> afaik, because most of the time people dont have musl and alpine docker container just makes things easier
<FromGitter> <Uzay-G> How can I declare an empty array of hashes in crystal?
<FromGitter> <Blacksmoke16> `arr = Array(Hash(String, String)).new`
<FromGitter> <Uzay-G> I can't do `Hash(k, v)`, but what is it you are supposed to use?
<FromGitter> <Blacksmoke16> have to type the hashes
<FromGitter> <tenebrousedge> I would use an alias, or several
<FromGitter> <tenebrousedge> eg
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd6325f3ce603074bb1068]
<FromGitter> <Uzay-G> how ould I initialize an array like this [{label: "", value: Int32}]`
<FromGitter> <Uzay-G> Can I like declare several keys of 1 hash?
<FromGitter> <tenebrousedge> you probably want a struct
<FromGitter> <tenebrousedge> `record MyObject, label = "", value = 0`
<FromGitter> <Uzay-G> yeah it needs to be a hash since it gets used in js ( complicated i know)
<FromGitter> <tenebrousedge> uh no
<FromGitter> <tenebrousedge> you can define serialization however you want
<FromGitter> <Uzay-G> no but i want the js to have my array look like Array(Hash())
<FromGitter> <tenebrousedge> you can serialize it to a hash if you want
<FromGitter> <kinxer> How are you interfacing with the JS?
<FromGitter> <tenebrousedge> well let's assume that they're not using C bindings to a js engine
<FromGitter> <Uzay-G> actually it's fine. I was using it inside slang with `#{}` notation but I actually don't need to represent it like that
<FromGitter> <Uzay-G> if you're curious, it's to make some `ChartJS` charts
yxhuvud has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<FromGitter> <tenebrousedge> I don't want to say that hashes in Crystal are less useful than in Ruby, but in Crystal it's less useful to use hashes as an ad-hoc data structure. Having to type your hash as `Hash(String, Int32 | String)` is unpleasant
<FromGitter> <xmonader> @Blacksmoke16 looks like that latest alpine has crystal 0.31 :(
<FromGitter> <Blacksmoke16> use the docker images
<FromGitter> <xmonader> that's the ones i used, maybe i should use nightly????
<FromGitter> <Blacksmoke16> what do you mean its `0.31.0`?
<FromGitter> <Blacksmoke16> can you share the command you ran?
<FromGitter> <Blacksmoke16> just pick the version you want `crystallang/crystal:0.34.0-alpine`
<FromGitter> <Blacksmoke16> would be `0.34.0` ofc
<FromGitter> <xmonader> ah i used the latest and it gave 0.31 :)
<FromGitter> <Blacksmoke16> really?
<FromGitter> <xmonader> yes
<FromGitter> <xmonader> i'm trying now the one u sent me
<FromGitter> <Blacksmoke16> what exactly did you use? `crystallang/crystal:latest` or?
<FromGitter> <xmonader> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd66aa2ac6ef4e88c72465]
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> i think something else is going on
<FromGitter> <xmonader> also this one ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd66f320d9bf3057653207]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd66faaac441316a7a4aed]
<FromGitter> <xmonader> hmmmm
<FromGitter> <Blacksmoke16> you're overriding the version prob
<FromGitter> <Blacksmoke16> `-v /opt/crystalalpine:/opt` like why is this needed?
<FromGitter> <xmonader> ok seems i'm doing smoething wrong ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd6732863019312a5cb798]
<FromGitter> <Blacksmoke16> yes
<FromGitter> <xmonader> hmm i need the volume mount to build the static binary in and use it in the host
<FromGitter> <Blacksmoke16> and your code you need to build is in `/opt/crystalalpine`?
<FromGitter> <xmonader> i'll move it there yes
<FromGitter> <Blacksmoke16> well no, just mount the dir the code is actually in
<FromGitter> <Blacksmoke16> https://crystal-lang.org/2020/02/02/alpine-based-docker-images.html like the example in here
<FromGitter> <xmonader> why? i'd adapt the same for building everything crystal that way
<FromGitter> <xmonader> so i need a more generic directory to have my projects in
<FromGitter> <Blacksmoke16> thats fine, then just swap out the dirs
yxhuvud has joined #crystal-lang
<FromGitter> <Blacksmoke16> oh wait
<FromGitter> <Blacksmoke16> `apk add crystal`
<FromGitter> <Blacksmoke16> why are you install crysatl?
<FromGitter> <xmonader> u r right indeed
<FromGitter> <xmonader> my bad :)
<FromGitter> <Blacksmoke16> so you're getting the latest version in `apk`
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <xmonader> works ^_^
<FromGitter> <xmonader> thank you!
<FromGitter> <Blacksmoke16> np
DTZUZU has quit [Quit: WeeChat 2.8]
<FromGitter> <xmonader> i can't get libzma to work ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd6af4da74582e921ba0e1]
<FromGitter> <Blacksmoke16> think you need to add like `--link-flags "$(pkg-config libxml-2.0 --libs --static)"`
<FromGitter> <Blacksmoke16> however, making sure the pkg-config runs inside the container
<FromGitter> <Blacksmoke16> why that is, im not sure, but :shrug:
<FromGitter> <xmonader> woooho!!!
<FromGitter> <xmonader> seems to build fine ^_^
<FromGitter> <xmonader> thank you a ton
<FromGitter> <Blacksmoke16> also be sure to include the normal flags like `--release --static`
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <Uzay-G> How can I convert a Time object into a human readable date format
<FromGitter> <Uzay-G> like just with year/month/day
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Time.html#to_s(format:String):String-instance-method
<FromGitter> <Uzay-G> thanks
<jhass> >> 7.days.ago
<DeBot> jhass: # => 2020-05-07 16:27:30.008579000 +00:00 - https://carc.in/#/r/92pg
<jhass> \o/
<FromGitter> <Blacksmoke16> > > 1 // 0
<FromGitter> <Blacksmoke16> :thinking:
<jhass> you'll need to come to the dark side of this bridge :D
<FromGitter> <Blacksmoke16> ha, or just pick a diff delimiter
<FromGitter> <Uzay-G> for some reason I get this when I use the formatting:
<FromGitter> <Uzay-G> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd7272aac441316a7a6d4c]
<FromGitter> <Uzay-G> but it works when i don't pass any arguments
<FromGitter> <Uzay-G> has this happened before?
<FromGitter> <Blacksmoke16> is possible your time is nil
<FromGitter> <tenebrousedge> or nilable
<FromGitter> <Blacksmoke16> ^
<FromGitter> <watzon> Wait, did you just add ICR to DeBot?
<FromGitter> <tenebrousedge> `try` is good
<FromGitter> <Uzay-G> that's at compile time
<FromGitter> <Blacksmoke16> or figure out if you can remove `nil` all together
<FromGitter> <Uzay-G> and I tried using `not_nil!`
<FromGitter> <Blacksmoke16> where if your time coming from?
<FromGitter> <Blacksmoke16> can you share some code
<FromGitter> <Uzay-G> oh no actually that worked
<FromGitter> <Uzay-G> I had the same problem in two areas
<FromGitter> <Uzay-G> so when i fixed problem 1 with `not_nil!`, I thought problem 1 still existed because there was the same problem :clumsy:
<FromGitter> <Blacksmoke16> but is it impossible for it to be nil?
<FromGitter> <Blacksmoke16> a better solution would be avoiding that union in the first place
<FromGitter> <tenebrousedge> yis
<FromGitter> <Uzay-G> yeah but again it's an automatic timestamp generated by granite
<FromGitter> <Blacksmoke16> ah, via `timestamps` macro?
<FromGitter> <Uzay-G> so I assume they must have that a Nil union
<FromGitter> <Uzay-G> yeah
<FromGitter> <Blacksmoke16> yea, since they wont have a value until its saved
<FromGitter> <Blacksmoke16> prob could define those with `property!` tho
<FromGitter> <Blacksmoke16> is one of my bigger questions in regards how to best handle it
<FromGitter> <Blacksmoke16> in reality those columns are not nilable
<FromGitter> <Blacksmoke16> but they have to be nilable on the model, similar to the PK
<FromGitter> <tenebrousedge> hmmmmm
<FromGitter> <Blacksmoke16> so you lose compile time saftey, but idk how else you would handle that
<FromGitter> <Blacksmoke16> w/o going into crazy `uninitialized` stuff
<FromGitter> <tenebrousedge> I dunno, it sounds like they would have to be nilable, unless an unsaved record had a different type
<FromGitter> <Blacksmoke16> yea, so runtime checks are best you're going to get
<FromGitter> <Blacksmoke16> kinda unfortunate, but makes the whole model much easier to work with. like partial hydration, etc
Dreamer3 has joined #crystal-lang
DTZUZU has joined #crystal-lang
<oprypin> i have `class A; def initialize(x); end; end; class B; def initialize(x, y); end; end`. can I define a method that implicitly refers to the base `new`? like `class B; def foo; self.new(x: 1); end; end`
<oprypin> important correction
<oprypin> i have `class A; def initialize(x); end; end; class B < A; def initialize(x, y); end; end`. can I define a method that implicitly refers to the base `new`? like `class B < A; def foo; self.new(x: 1); end; end`
<FromGitter> <tenebrousedge> `previous_def` is a thing
<FromGitter> <asterite> ```puts "hello world"```
<FromGitter> <Blacksmoke16> ```def initialize(x, y) ⏎ super x ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ebd87ff20d9bf3057659e04]
<FromGitter> <tenebrousedge> hmmm, or that
<oprypin> Blacksmoke16, but this is not inside initialize
<FromGitter> <Blacksmoke16> did you mean `def self.foo`?
<oprypin> no
<FromGitter> <Blacksmoke16> `self.class.new(x: 1)`?
<FromGitter> <Blacksmoke16> but idt that'll work as it'll leave `y` uninitialized
<oprypin> doesnt work https://carc.in/#/r/92q2
<FromGitter> <Blacksmoke16> as `self.class` would be `B`
<FromGitter> <Blacksmoke16> whats the goal here?
<oprypin> i know that i can do `def foo; A.new(x: 1); end` but i want it to be implicit
<FromGitter> <Blacksmoke16> do you always want it to return the parent?
<FromGitter> <Blacksmoke16> https://carc.in/#/r/92q4
<FromGitter> <Blacksmoke16> that would work
<oprypin> honestly though i should just `s/typeof(self)/View/`
<FromGitter> <Blacksmoke16> would have to go the macro route then, in order to get the parent type
<FromGitter> <Blacksmoke16> otherwise `self.class` would be the current type, which chances are would require all vars to be given
<FromGitter> <bararchy> How can one change the Format of the new Log module?
<FromGitter> <bararchy> Also, is there a way to to create custom Severity level?
<FromGitter> <Blacksmoke16> yes, and no
<oprypin> hmm the latter one is an oof
<FromGitter> <Blacksmoke16> @bararchy https://crystal-lang.org/api/master/Log/IOBackend.html#new(io=STDOUT,formatter:Formatter=ShortFormat)-class-method
<oprypin> i think number-based severity is quite common elsewhere
<FromGitter> <Blacksmoke16> only the `IOBackend` has support for it
<FromGitter> <Blacksmoke16> and/or custom backends
<FromGitter> <Blacksmoke16> but is a `formatter=` and/or can be set in initializer
<FromGitter> <Blacksmoke16> each log severity *has* a number inherently
<FromGitter> <Blacksmoke16> but there isnt a dynamic like `log(severity : Log::Severity)`
<FromGitter> <Blacksmoke16> so you cant even do `Log::Severity.new 234`
<FromGitter> <bararchy> I see
<FromGitter> <bararchy> and as we can't reopen enums I can't even monkey patch it
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> How would the formatter syntax work like? the docs are a bit confusing
<FromGitter> <Blacksmoke16> simplest example would be like
<FromGitter> <Blacksmoke16> ```formatter = Log::Formatter.new do |io, entry| ⏎ io << entry.message ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ebd95f6f3ce603074bba61d]
<FromGitter> <Blacksmoke16> just a proc that yields the entry, and an IO to write the data to
<FromGitter> <bararchy> hm... so I can create a custom formatter that will embed by custom severity message
<FromGitter> <Blacksmoke16> i suppose
<FromGitter> <bararchy> ```Log.define_formatter MyFormat, "- #{severity}: #{message}" ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5ebd9686ecc55a312d025da0]
<FromGitter> <Blacksmoke16> sure, and just override the `severity` method afaik
<FromGitter> <bararchy> cool
<oprypin> i just realized something amazing. that github still renders its UI server-side 🥰
<FromGitter> <tenebrousedge> it's still a Rails app AFAIK
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd993f6675d830b1a751e3]
<FromGitter> <bararchy> This is a working example to make custom level on 0.34.0, it still is a bummer that I can't just make new Severity :\ I guess I need two Log now
<FromGitter> <bararchy> CustomLog = *** ⏎ Log = ***
<FromGitter> <bararchy> 😢
<FromGitter> <Blacksmoke16> well to be clear, that would use `MyLevel` all the time
<FromGitter> <Blacksmoke16> i.e. that would be the only option...
<FromGitter> <bararchy> Yeha, hence two Logs
<FromGitter> <Blacksmoke16> two logs?
<FromGitter> <bararchy> Regular `Log` defined with regular levels, then define CustomLog with the custom level
<FromGitter> <Blacksmoke16> that would print `MyLevel: Message` no matter what log method you call. I.e. same for `Log.error ...`
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebd99ed20d9bf305765d1dc]
<FromGitter> <Blacksmoke16> ah
<FromGitter> <bararchy> yeha, fully aware :\ hence, define two logs
<FromGitter> <bararchy> hahaha
<FromGitter> <Blacksmoke16> imo you could get the same effect using metdata
<FromGitter> <Blacksmoke16> if given, use that, otherwise fallback on `entry#severity`
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <Blacksmoke16> whats the actual usecase for a custom severity?
<FromGitter> <bararchy> Allowing to filter specific logs so that it can be feed into a customer facing system without exposing data
<FromGitter> <Blacksmoke16> wouldnt that be better suited to a metadata/context value?
<FromGitter> <bararchy> What would that give me? (I'm a bit new to the new log module)
<FromGitter> <Blacksmoke16> i imagine you have a backend to kibana or something?
<FromGitter> <Blacksmoke16> that you want these specific logs to go to?
<FromGitter> <bararchy> I see, so sadly the source of the logs will all be STDOUT, it's running inside an AWS fargate task, and then using cloudwatch API being feed into the relevant system
<FromGitter> <Blacksmoke16> (will need to wait for `0.35.0` for this but ) `Log.info &.emit("User logged in", user_id: 42)`
<FromGitter> <Blacksmoke16> i.e. `Log.info &.emit("Message", public: true)`
<FromGitter> <Blacksmoke16> or `priority: Priority::Public`, which you could then use that key/value to do the filtering
<FromGitter> <Blacksmoke16> or something along those lines?
<FromGitter> <bararchy> makes sense, I guess I can just instead use one of the levels I'm not usually using like NOTICE or VERBOSE, maybe that would be the easiest thing right now
<FromGitter> <Blacksmoke16> that too
kradnoel has joined #crystal-lang
rocx has quit [Ping timeout: 260 seconds]
<FromGitter> <Blacksmoke16> oprypin: but how do those artifacts make it into GH Actions?
<FromGitter> <Blacksmoke16> like when building his diffing binary
<jhass> oprypin: mmh they're still pushing HTML for the live updating stuff?
<jhass> I mean it's by no means a JS free frontend
<jhass> but maybe it actually degrades nicely, I never tried
<oprypin> @Blacksmoke16: the action literally scours through artifacts of the repo crystal-lang/crystal
<oprypin> u can check the source code :>
<oprypin> that's not the word i wanted
<oprypin> ah no there is a usage of it like that
<FromGitter> <Blacksmoke16> ah its something your `install-crystal` thing does
<oprypin> yes
<FromGitter> <Blacksmoke16> might have to look into that for making an `oq` binary for windows :0
<oprypin> inb4 running it through Wine is the most portable approach on Linux
<oprypin> i should actually try it in Wine, how have i not thought of that
_ht has quit [Remote host closed the connection]
<FromGitter> <kinxer> I'm sure this is something that's been discussed, but does anyone know what's going on here? ⏎ https://carc.in/#/r/92qu vs https://carc.in/#/r/92qv
<oprypin> @kinxer, the `self.class` means it accepts literally just the type `Gubbin`, not instances of it
<FromGitter> <kinxer> Oof. Right. Thank you.
<FromGitter> <kinxer> I've been in Java-land recently, and it's messing with my head.
<jhass> but shouldn't either version just define two overloads?
<jhass> I call remant from the compiled ruby days where it tried to emulate Ruby's lexical scoping
<FromGitter> <kinxer> Here's the behavior I was trying to replicate: https://carc.in/#/r/92r6 vs https://carc.in/#/r/92r8
<FromGitter> <kinxer> It seems pretty clear what's going on there, though. Thanks for correcting my unnecessary `.class`.
<jhass> oh, both is a class so it overrides
<jhass> mh, no ok I don't get this
<FromGitter> <kinxer> Also, for the sake of clarity, the solution for the `.class` version (if that was what I actually wanted) was to declare `Gubbins`, declare `LilGubbins`, and then re-open `Gubbins` to add the method that required `LilGubbins` to be defined.
<oprypin> what :D it sounds so funny
<oprypin> i cant get over it
<FromGitter> <kinxer> I just wanted to have more fun with class names. :P
<raz> it seems to make sense to me. Gubbin is more specific than LilGubbin
<raz> but...
<jhass> why would the order you define these in matter though
<raz> well, they do
<jhass> I mean for the compile error
<FromGitter> <kinxer> Well, that is a fair point. I'd expect it to error in both cases in the (accidental) `.class` example.
<jhass> I would understand if the one where it comes seconds errors out because it overrides the first one and thus the first one is never called but idk
<jhass> it all doesn't make real sense
<raz> yea, i don't understand why the first declared one take precedence
<raz> i would've thought it gets overwritten if both declarations result in the same thing
<jhass> maybe the override triggers the error to check if it should overload or override, idk
<jhass> but then why wouldn't it need to instantiate the argument for that check in the other case
<FromGitter> <kinxer> Oh, yeah. I wonder if that's it. The compiler doesn't *need* to know anything about that type before the method it overridden.
<raz> oh, actually, i guess it does make sense. the compiler just keeps both and checks them in order as declared. both match, so the first one wins.
<FromGitter> <kinxer> I guess there's something different between doing that check for `Klass` and `Klass.class`?
<jhass> mmh, maybe
<raz> having declaration order matter like that feels like a bug waiting to happen tho
<jhass> well actually in the error case one doesn't match, if both match both ways work
<raz> i wonder if the compiler could/should guarantee that the more specific match wins, regardless of declaration order
<oprypin> raz, it does that normally
<oprypin> just that in this case apparently it sees them as equally specific
<FromGitter> <kinxer> To be honest, it's a little confusing that when you override a method exactly (in the same type), the newer definition wins, whereas when the methods are different but the compiler can't decide on one, the *older* definition wins.
lanodan has quit [Ping timeout: 265 seconds]
<FromGitter> <kinxer> Okay, uh... There's this, I guess?
<raz> anyway, fixed
<FromGitter> <kinxer> Lol. Thanks for the help, @raz.
<raz> yw, and sorry. i'll go have my beer now, these gubbies melt my brain ;)
lanodan has joined #crystal-lang
<FromGitter> <kinxer> For explanation of the links I just sent, basically it seems like the behavior is the following (where `def` means an exact method signature, and `defX'` is a re-definition with the exact method signature of `defX` but a different body): ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ebdbcb013878c30b57d26bb]
Dreamer3 has quit [Quit: Leaving...]
kradnoel has quit [Remote host closed the connection]
rocx has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 2.8]