Hi,
I’m new to Juce, and haven’t done any C++ coding in over 10 years. Was doing JavaScript and Swift recently. Anyway, I’m trying to figure out how to use Logger to log to a file (I’m creating a plugin), and not getting anywhere. I looked through the example code, the tutorials and GitHub, as well as this forum.
Not being an expert C++ developer and finding the documentation on JUCE lacking useful examples of how to use the API is driving me bonkers. Thinking I might be better off trying the VST SDK first before getting too deep into JUCE.
Questions:
- To log to a file should I be using Logger or FileLogger? I have basic dev console logging working OK. I tried the following code and got these compile time errors:
unknown type name: fileLog
then complains about arrow → in 2nd line. I tried with ‘.’ and won’t work either.
FileLogger fileLog();
fileLog->createDateStampedLogger(“TailGunnerSr”, “TailGunnerSr”, “.log”, “Tail Gunner Sr - Log File”);
-
I have the above code in a separate header file: myLogger.h does that make sense?
-
I also tried the following, however the plugin crashes since the file “tail-gun-test.log” doesn’t exist. I thought the FileLogger constructor would create a new file if one doesn’t exist as per the docs:
fileToWriteTo the file that to use - new messages will be appended to the file. If the file doesn’t exist, it will be created, along with any parent directories that are needed.
JUCE: FileLogger Class Reference
The code below crashes. If I change the File constructor to just:
File logfile;
Then it logs to the dev console OK, but doesn’t create a new file.
This is the code that crashes:
// in myLogger.h
File logfile(“tail-gun-test.log”);
FileLogger fileLog(logfile, “Welcome to Application”, 1000);// in PluginEditor.cpp
fileLog.logMessage(“Testing 1 2 3!!!\n”);
Thanks for reading this far Hope you can shine a light.