Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider libfmt for Log #121

Open
z33ky opened this issue Jan 23, 2018 · 5 comments
Open

Consider libfmt for Log #121

z33ky opened this issue Jan 23, 2018 · 5 comments

Comments

@z33ky
Copy link
Collaborator

z33ky commented Jan 23, 2018

Consider using fmt for Log().

@Quaker762
Copy link
Member

hmm looks really good. What sort of improvements would this have over what we've currently got though? For the most part, Log() does what we need it to (print to stderr and Log.txt). Some kind of safety? (from what I can read)

@z33ky
Copy link
Collaborator Author

z33ky commented Jan 24, 2018

"Support for user-defined types" is the major motivator for me. Being able to just Log(LogLevel::WARN, "{} does not align with {}\n", vecA, vecB) instead of Log(LogLevel::WARN, "%f %f %f does not align with %f %f %f\n", vecA.x, vecA.y, vecA.z, vecB.x, vecB.y, vecB.z) is a big improvement. Of course we could also use macros to trim it down some:

#define VEC_FMT "%f %f %f"
//FIXME: if vec is evaluated multiple times
#define VEC_FMT_ARG(vec) (vec).x, (vec).y, (vec).z
...
Log(LogLevel::WARN, VEC_FMT " does not align with " VEC_FMT, VEC_FMT_ARG(vecA), VEC_FMT_ARG(vecB));

Neither works well if we want to customize vector printing though, e.g. if we just want to print two decimal places. In either case we can still fall back to vecA.x, vecA.y, vecA.z. We could perhaps look if we can extent fmt for that usecase though. With just printf we could implement parsing of the format string ourselves, which is not terribly defficult, but I think still wasted effort.

@z33ky
Copy link
Collaborator Author

z33ky commented Jan 24, 2018

Err okay, that last thing is already possible in fmt: http://fmtlib.net/latest/api.html#formatting-user-defined-types

Edit: link correct section

@Quaker762
Copy link
Member

Did you still want to use this? I just had another look and it'll definitely make our lives a whole lot easier.

I'll leave it up to you though, it'll be a disaster if I do it hahaha.

@Quaker762 Quaker762 added this to To do in TODO Feb 20, 2018
@z33ky
Copy link
Collaborator Author

z33ky commented Feb 21, 2018

Yes, I still believe this is a good option for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
TODO
  
To do
Development

No branches or pull requests

2 participants