How to use the FileLogger

Hello JUCE-Board!

I’m making my first steps with JCUE (though not my first steps with OO-programming) and I’m fairly new to C++, too. So my question is most likely answered in a few sentences, but that’s worth a lot for me, because I can’t get my Logger running without freezing my app.

Ok, here’s what I want to do: I want to write a VST Plugin with JUCE. During construction, I’d like to have stuff logged to a file to see where the plugin hangs or crashes. So basically I have the AudioProcessor class, that has a member variable m_log_file and m_logger just like this:[code]class R7AudioProcessor : public AudioProcessor
{
public:
//==============================================================================
R7AudioProcessor();
~R7AudioProcessor();

...
...

FileLogger m_logger;
File m_log_file;

...

};[/code]

For reasons of RAII i tried it like this, and did not want to use pointers. Now I’m wondering how to corectly initialise these two members. I tried it like this: R7AudioProcessor::R7AudioProcessor() :m_log_file("C:\\Log.txt"), m_logger(m_log_file,"Welcome to the log",0) { }
When I run this in a VST-Host, it freezes.

So here is my question: How can I force these two members to be constructed before all other members, so log messages about the construction of my vst can be written to a file?

Thanks a lot,
StrangeMan

It may just be having a problem because the logger will be initialised before the file that you’re passing to it. Presumably you’re on Windows, because GCC/clang would have warned you about that. Try swapping the order of your member variables around to match the order in which you initialise them.

Most of the time its easier to use the debugger :slight_smile:

Oh, great, that did it. Thanks, works like a charm now.

Thanks for JUCE, makes things a loooot easier for me. Tried it with VSTgui before - pure horror for a beginner…