filipwasil / fillwave

Multiplatform C++14 graphics engine
https://filipwasildev.bitbucket.io/
MIT License
23 stars 6 forks source link

Use spdlog for logging #93

Closed filipwasil closed 7 years ago

filipwasil commented 7 years ago

https://github.com/gabime/spdlog

This library is great for logging. It may be a bit difficult but we really should consider using it instead of old fashioned FLOG_XXX macros. Sometimes they are so lame to work with...

1) add this library as git submodule in ext directory 2) Provide each module with appropriate headers 3) Replace all usages of FLOG's with spdlog

filipwasil commented 7 years ago

Why did You revert all changes i did ? I fixed this already

KeramKeram commented 7 years ago

Ahh.. I didn't see changes in reveiw I focused on error(I imply didn't download patch) :) But I puhed my changes as other review. I will check your changes and submit them.

filipwasil commented 7 years ago

There is still one thing missing. The log content is not displayed. Only the info about tag and File.

filipwasil commented 7 years ago

Perfect ! But as i said. My xhanges are not Perfect either :p however this should be easy to fix. Probably ... :P

KeramKeram commented 7 years ago

I will check this later now I reading about opengl. But perhaps some problem with _VARARGS

KeramKeram commented 7 years ago

check this: "[2016-10-22 19:44:22.333] [Program] [critical] attach shader %d to program %d" That means you send only first argument from var_args, first we should construct c_string and next send to spdlog. I will fix this soon.

KeramKeram commented 7 years ago

ahh turn on colors in terminal?

KeramKeram commented 7 years ago

"(::tag + ":" + std::to_string(LINE)).c_str(), VA_ARGS)" using _VAARGS in that way can be tricky(or even impossible) but I'm investigating it now(because it is macro not function it can be impossible to use sprintf/vnsprintf without formater ).

KeramKeram commented 7 years ago

I think we are unable to use var args in that way we need(even with ##_varargs). Because like in c++ doc. we need something like that to create c string

void PrintFError ( const char * format, ... )
{
  char buffer[256];
  va_list args;
  va_start (args, format);
  vsnprintf (buffer,256,format, args);
  perror (buffer);
  va_end (args);
}

By using macro it is possible but it hard and have some limitations. My inline/static function with new adjustments for exception works(I tested it). Try to adjust in some way macro or go to inline/static function(I take macros etc. fro your code and integrate it)?

filipwasil commented 7 years ago

What limitations ? I used macro and everything is fine.

Overall runtume performance: 2xsprintf + spdloag call

Overall init performance 1000 bytes per module 1 copy of shared pointer per module

Known issues. If two modules will have the same name, there will be a runtime exception.

Last question is: How to handle this ?

filipwasil commented 7 years ago

also hardcoded 1000 is not nice

KeramKeram commented 7 years ago

Now we send to spdlog _var_args but we are unable to print correct messages(for example we cannot substitute %d by number in log) see log from my previous post. We expect that we will be able to do this. In that case we need first print data to some buffer, Ok looks simple(example macro)


#define Mymacro(...) sprintf(buffer,_var_args);
It's wrong.
Ok perhaps:
#define Mymacro(msg, ...) sprintf(buffer, msg, _var_args);
Almost there but:
Mymacro("tekst");
It will be error. It is well know problem and we need one more parameter:
Mymacro("tekst",NULL)

On stackoverflow there is solution but is not elegant and number of arguments is limited.

KeramKeram commented 7 years ago

Even in spdlog is something like this to avoid problem with empty var_args

template <typename... Args>
inline void spdlog::logger::warn(const char* fmt, const Args&... args)
{
    log(level::warn, fmt, args...);
}
KeramKeram commented 7 years ago

I have error compilation because, during building I have unused variable(what is strange): static char buffer[FILLWAVE_LOG_BUFFER_SIZE];

You do not have any problems? I will fix this tomorrow night now I go to bed :)

filipwasil commented 7 years ago

FILLWAVE_LOG_BUFFER_SIZE or buffer is not used ?

filipwasil commented 7 years ago

and in which file ?

filipwasil commented 7 years ago

Paste whole error

pon., 24.10.2016, 22:53 użytkownik revcorey notifications@github.com napisał:

I have error compilation because, during building I have unused variable(what is strange): static char buffer[FILLWAVE_LOG_BUFFER_SIZE];

You do not have any problems?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/filipwasil/fillwave/issues/93#issuecomment-255862967, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxGvSOR-OwmIw3y3fs0QYUgkmvmsdEuks5q3RrWgaJpZM4KDOXj .

KeramKeram commented 7 years ago

I do some things with this buffer but now I have another errors. I will try build this on vm with ubuntu.

filipwasil commented 7 years ago

seems like an easy issue. what is the error message ?

filipwasil commented 7 years ago

Issues with release fixed.

filipwasil commented 7 years ago

I still need to know in which source file the static buffer was not used :)

KeramKeram commented 7 years ago

In few files actually, I use trick. I use std::fill() to fill zeros in array(for tests).

Another problem is wierd, it is problem with macro FLOGINIT, I have problem with internet on VM but I will take my laptop to work and download fillwave to vm and will try build, I give you response on skype.

filipwasil commented 7 years ago

ok, fixed

KeramKeram commented 7 years ago

Scanning dependencies of target textureloader Scanning dependencies of target fontgenerator [ 1%] Building CXX object ext/fontgenerator/CMakeFiles/fontgenerator.dir/fontGenerator.cpp.o /home/radek/fillwave/ext/fontgenerator/fontGenerator.cpp:13:29: fatal error: stb_image_write.h: Nie ma takiego pliku ani katalogu compilation terminated. ext/fontgenerator/CMakeFiles/fontgenerator.dir/build.make:62: polecenia dla obiektu 'ext/fontgenerator/CMakeFiles/fontgenerator.dir/fontGenerator.cpp.o' nie powiodły się make[2]: * [ext/fontgenerator/CMakeFiles/fontgenerator.dir/fontGenerator.cpp.o] Błąd 1 CMakeFiles/Makefile2:196: polecenia dla obiektu 'ext/fontgenerator/CMakeFiles/fontgenerator.dir/all' nie powiodły się make[1]: * [ext/fontgenerator/CMakeFiles/fontgenerator.dir/all] Błąd 2 make[1]: * Oczekiwanie na niezakończone zadania.... [ 2%] Building CXX object src/loaders/TextureLoader/CMakeFiles/textureloader.dir/TextureLoader.cpp.o In file included from /home/radek/fillwave/src/loaders/TextureLoader/TextureLoader.cpp:37:0: /home/radek/fillwave/inc/fillwave/Texturing.h:43:23: fatal error: stb_image.h: Nie ma takiego pliku ani katalogu compilation terminated. src/loaders/TextureLoader/CMakeFiles/textureloader.dir/build.make:62: polecenia dla obiektu 'src/loaders/TextureLoader/CMakeFiles/textureloader.dir/TextureLoader.cpp.o' nie powiodły się make[2]: * [src/loaders/TextureLoader/CMakeFiles/textureloader.dir/TextureLoader.cpp.o] Błąd 1 CMakeFiles/Makefile2:123: polecenia dla obiektu 'src/loaders/TextureLoader/CMakeFiles/textureloader.dir/all' nie powiodły się make[1]: * [src/loaders/TextureLoader/CMakeFiles/textureloader.dir/all] Błąd 2 Makefile:149: polecenia dla obiektu 'all' nie powiodły się make: * [all] Błąd 2 dpkg: błąd przetwarzania archiwum ./libfillwave--Linux.deb (--install): brak dostępu do archiwum: Nie ma takiego pliku ani katalogu Wystąpiły błędy podczas przetwarzania: ./libfillwave--Linux.deb -- Eclipse version is set to 4.4 (). Adjust CMAKE_ECLIPSE_VERSION if this is wrong. Building development package CMake Warning (dev) at cmake/platform/LinuxDev.cmake:11 (project): Policy CMP0048 is not set: project() command manages VERSION variables. Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

The following variable(s) would be set to empty:

PROJECT_VERSION

Call Stack (most recent call first): CMakeLists.txt:120 (include) This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done -- Generating done -- Build files have been written to: /home/radek/fillwave_build [ 50%] Building CXX object src/loaders/TextureLoader/CMakeFiles/textureloader.dir/TextureLoader.cpp.o In file included from /home/radek/fillwave/src/loaders/TextureLoader/TextureLoader.cpp:37:0: /home/radek/fillwave/inc/fillwave/Texturing.h:43:23: fatal error: stb_image.h: Nie ma takiego pliku ani katalogu compilation terminated. src/loaders/TextureLoader/CMakeFiles/textureloader.dir/build.make:62: polecenia dla obiektu 'src/loaders/TextureLoader/CMakeFiles/textureloader.dir/TextureLoader.cpp.o' nie powiodły się make[2]: * [src/loaders/TextureLoader/CMakeFiles/textureloader.dir/TextureLoader.cpp.o] Błąd 1 CMakeFiles/Makefile2:85: polecenia dla obiektu 'src/loaders/TextureLoader/CMakeFiles/textureloader.dir/all' nie powiodły się make[1]: * [src/loaders/TextureLoader/CMakeFiles/textureloader.dir/all] Błąd 2 Makefile:149: polecenia dla obiektu 'all' nie powiodły się make: ** [all] Błąd 2 dpkg: błąd przetwarzania archiwum ./libfillwave-dev--Linux.deb (--install): brak dostępu do archiwum: Nie ma takiego pliku ani katalogu Wystąpiły błędy podczas przetwarzania:

KeramKeram commented 7 years ago

I'm introducing macro:

define UNUSED(x) ((void)(x))

to avoid unsued variable error.

KeramKeram commented 7 years ago

I see that is only one log is a problem, rest of them is working(Program] [critical] attach shader %d to program %d). I will push changes, and rebuild it's on ubuntu. If you accept this new macro I will merg patch to branch and marta can start her work with cmakes.

KeramKeram commented 7 years ago

i will push this tomorrow!

filipwasil commented 7 years ago

Do not make Thai macro. In check function there is already a (void)buffer and (void)mask. Are you sure you are testing the newest changeset ?

KeramKeram commented 7 years ago

I have downloaded patch-set 10 from gerrit(for tests I used fetch not pull). There was (void)buffer in some places but still in some files had problems, and that is interesting because on ubuntu it works!

filipwasil commented 7 years ago

On Fedora buffer in program.cpp is unused ?

KeramKeram commented 7 years ago

In few files, As I rember there are files who do not use any flog hmm... Terrain.cpp ? I added My macro to few cpp files and everything compiles now(by linux build script).

KeramKeram commented 7 years ago

Ok, problem is FLOGINIT. I'm currently removing it. Soon on gerrit.

KeramKeram commented 7 years ago

on gerrit. Submit it?

KeramKeram commented 7 years ago

Submited, Now Marta can start with Cmake 1) Analysis how glm is add in cmake's 2)add spdlog to externals 3)add spdlog to cmake's like glm.

filipwasil commented 7 years ago

Windows build is failing because of spd log missing.

@aerie94 ?