After a little bit of research, I found out that you can actually use rgb values to set the colors. If the terminal supports true color you can use: This code: \33[38;2; ; ; m for foreground color and this code \33[48;2; ; ; m for background color. (don't put spaces, I put them there for easier visibility) Reset stays the same Where r, g and b can range from 0 to 255 depending on the rgb value of the color you want. Let's say you want Persian Green (code: 42, 157, 143) in logging.INFO You could do: logging.INFO: f"\33[38;2;42;157;143m{FMT}\33[0m" This gives you more control of what colors you wanna use, although it would be wise to check if the console supports true color before using them. I failed to find a way to check this automatically (through python) so if any of you have a solution and would like to share I'm sure everyone could benefit from it :) edit: my tests were made in windows terminal, in case someone wants to know
This is actually super cool info! I know there's a way to check if a terminal supports colour (though I don't know the way personally), but yeah not sure about the true colour thing. Would be cool to know though.
Just saw a notification for your comment -- looks like it got autoremoved cos it contained a link. If you wanna repost it with a modified like (like replacing the . with "dot") go for it haha.
Ayu Mirage Bordered + Fira Code as the font. I'm tempted to make a video about it cos a lot of people seem to really like it haha. Glad you liked the video!
@@Carberra Thanks you. Good idea haha but i'm still waiting for the hikari series hahahaha. I really like your way of coding so I think it will be very good
Me too! I'm waiting for the stable to release, just so no breaking changes come in half way through the series haha. ETA for that is April atm. I'll probably make some more supplementary videos in the meantime.
Once you've configued the logger, it'll work anywhere in your program. If you mean how to get it working across multiple programs, you would just want to import and run some function from a shared module that sets it all up.
This video gave me an idea for something I can add to my bots error handler. I've normally just dealt with standard error messages of 'Something broke becuase of xyz" however I had an idea to add in some more useful informaation such as the server ID/Name where the error occcured, the user ID/Name who caused the error (if it's triggered by a user), the command that was used, the time and date it occured (in UTC) and then the information about the error. Is it possible to add such features to a errror handler and if so would you mind making a video about it at some point as I'm not very famiar with what information I can get from errors (I do read docs about them).
Yeah that's definitely possible. If you're using discord.py, the context gets passed through (same context as the command used), and on Hikari, you have event.context. The non-command error handlers have similar mechanisms but I'm less familiar with those.
@@Carberra - tried adding here but it didn't work. I'm guessing format is somewhere else? handler = logging.StreamHandler() handler.setFormatter(CustomFormatter()) logging.basicConfig( level=logging.DEBUG, format='%(asctime)s', handlers=[handler], )
After a little bit of research, I found out that you can actually use rgb values to set the colors.
If the terminal supports true color you can use:
This code: \33[38;2; ; ; m for foreground color and
this code \33[48;2; ; ; m for background color. (don't put spaces, I put them there for easier visibility)
Reset stays the same
Where r, g and b can range from 0 to 255 depending on the rgb value of the color you want.
Let's say you want Persian Green (code: 42, 157, 143) in logging.INFO
You could do:
logging.INFO: f"\33[38;2;42;157;143m{FMT}\33[0m"
This gives you more control of what colors you wanna use, although it would be wise to check if the console supports true color before using them.
I failed to find a way to check this automatically (through python) so if any of you have a solution and would like to share I'm sure everyone could benefit from it :)
edit: my tests were made in windows terminal, in case someone wants to know
This is actually super cool info! I know there's a way to check if a terminal supports colour (though I don't know the way personally), but yeah not sure about the true colour thing. Would be cool to know though.
Just saw a notification for your comment -- looks like it got autoremoved cos it contained a link. If you wanna repost it with a modified like (like replacing the . with "dot") go for it haha.
clean & straight to the point like every tutorial should be 👍
Glad you enjoyed it!
Cool video 🤩
Just out of curiosity, it seems you mostly use your keyboard, have you ever tried the vim extension form vs? 🤔
Thanks!
I haven't, but I have tried Vim itself before, and I just get muddled honestly. I'm so used to the ones I know haha.
@@Carberra Yeah, I believe it's harder to get rid of old habits than to make new ones :))
Another great video!
Once, I asked about this in Hikari's Discord server. And here we are with a tutorial on. What a pleasant coincidence! (Or is it 👀)
Probably a bit of both -- I went to learn it for my own purposes, but I've seen a few people ask about it before. Pretty convenient either way though!
Great video!. What is that VS theme?
Ayu Mirage Bordered + Fira Code as the font. I'm tempted to make a video about it cos a lot of people seem to really like it haha. Glad you liked the video!
@@Carberra Thanks you. Good idea haha but i'm still waiting for the hikari series hahahaha. I really like your way of coding so I think it will be very good
Me too! I'm waiting for the stable to release, just so no breaking changes come in half way through the series haha. ETA for that is April atm. I'll probably make some more supplementary videos in the meantime.
So how would you use this in a different files and modules
Once you've configued the logger, it'll work anywhere in your program. If you mean how to get it working across multiple programs, you would just want to import and run some function from a shared module that sets it all up.
This video gave me an idea for something I can add to my bots error handler. I've normally just dealt with standard error messages of 'Something broke becuase of xyz" however I had an idea to add in some more useful informaation such as the server ID/Name where the error occcured, the user ID/Name who caused the error (if it's triggered by a user), the command that was used, the time and date it occured (in UTC) and then the information about the error. Is it possible to add such features to a errror handler and if so would you mind making a video about it at some point as I'm not very famiar with what information I can get from errors (I do read docs about them).
Yeah that's definitely possible. If you're using discord.py, the context gets passed through (same context as the command used), and on Hikari, you have event.context. The non-command error handlers have similar mechanisms but I'm less familiar with those.
How can you get the timestamp added to each of the logs?
Include `%(asctime)s` in the format.
@@Carberra - tried adding here but it didn't work. I'm guessing format is somewhere else?
handler = logging.StreamHandler()
handler.setFormatter(CustomFormatter())
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s',
handlers=[handler],
)
Hi...is the code for this available? I am not seeing it in the repository..."How its Done"
That repo isn't updated. You'll need to copy the code from the video.
Really helpful
найс :kappa: