C++ wxWidgets scrollable wxTextCtrl as a status logger

I'm trying to create a wxTextCtrl that i log messages to similar to a console. It needs to hold multiple lines, and whenever a new line is added, the line should be appended to the bottom of the list of previous lines and the textctrl should say scrolled max to the bottom so can always see most recent lines.

I've successfully created the scrollable wxTextCtrl and can log messages to it fine. I can scroll up and down manually to check the messages, but it doesnt scroll down automatically when i add new lines, and also does not stay scrolled down as a i add new lines. Any help would be appreciated

Here is the definition of the wxTextCtrl in the frame constructor:

logOutput = new wxTextCtrl(mainPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
outputSizer ->Add(logOutput, wxSizerFlags(1).Expand());

And here is the code to add lines to it, defined in a method of a seperate class. I found this example code here:https://wiki.wxwidgets.org/WxTextCtrl

// grows log output
void growLogOutputLines(std::string add_line, wxTextCtrl *log_output)
    // convert std::string add_line to wx string
    wxString add_line_wx = wxString::Format(wxT("%s"), add_line) + wxT("\n");

    log_output->Freeze();                 // Freeze the window to prevent scrollbar jumping
    log_output->AppendText( add_line_wx );          // Add the text
    log_output->ScrollLines( 1 ); // Scroll down 1 line
    log_output->ShowPosition( log_output->GetLastPosition() ); // Ensure the last line is shown at the very bottom of the window