Ability to specify custom logfile globally and per-function #3

Closed
opened 2024-06-17 15:26:47 -04:00 by josh · 6 comments
Owner
No description provided.
josh was assigned by maxine 2024-06-24 19:38:51 -04:00
maxine self-assigned this 2024-06-24 19:38:51 -04:00
maxine added the
Status
Need More Info
label 2024-06-24 19:39:31 -04:00
josh added a new dependency 2024-06-25 12:23:07 -04:00
Collaborator

Status update?

Status update?
Collaborator

If we want globally we basically already got that. I think the easiest and best approach would be to modify the jlog::log function to accept both the tokens and the log file name. Then we just write a wrapper for using the global log file. This way we can easily do a log file per function.

All we gotta do is use a base jlog::log function like this.

void baselog(std::vector<token> tokens, const std::string& filename);

And have the global one defined too which is just a wrapper for the first one.

void log(std::vector<token> tokens);
If we want globally we basically already got that. I think the easiest and best approach would be to modify the jlog::log function to accept both the tokens and the log file name. Then we just write a wrapper for using the global log file. This way we can easily do a log file per function. All we gotta do is use a base jlog::log function like this. ``` void baselog(std::vector<token> tokens, const std::string& filename); ``` And have the global one defined too which is just a wrapper for the first one. ``` void log(std::vector<token> tokens); ```
Collaborator

We can probably implement something like the ERROR macro this way.

#define ERROR(i)   if (jlog::loglevel >= jlog::severity::error) { jlog::baselog(jlog::error_detailed_format(i, FUNCTION, __FILE__, __LINE__), "errors.log"); }
We can probably implement something like the ERROR macro this way. ``` #define ERROR(i) if (jlog::loglevel >= jlog::severity::error) { jlog::baselog(jlog::error_detailed_format(i, FUNCTION, __FILE__, __LINE__), "errors.log"); } ```
Author
Owner

I've implemented log_to_file(filename, message) variant aswell as a set_default_logfile method. I consider this issue closed, but if you have any further input go for it.

I've implemented log_to_file(filename, message) variant aswell as a set_default_logfile method. I consider this issue closed, but if you have any further input go for it.
Collaborator

Kinda got this working. The global logger is inside of the shared header. It's pretty generic afaik

Kinda got this working. The global logger is inside of the shared header. It's pretty generic afaik
Collaborator

I got this done even better. Way more flexible now and way easier to implement custom loggers.

3e414abc8d

I got this done even better. Way more flexible now and way easier to implement custom loggers. https://git.redacted.cc/josh/jlog/commit/3e414abc8d85a16ad379f81879d31c4a818579fa
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Reference: josh/jlog#3
No description provided.