void TSessionLog::Add(TLogLineType Type, UnicodeString ALine)
{
  DebugAssert(FConfiguration);
  if (GetLogging())
  {
    try
    {
      if (FParent != nullptr)
      {
        DoAdd(Type, ALine, nb::bind(&TSessionLog::DoAddToParent, this));
      }
      else
      {
        TGuard Guard(FCriticalSection);

        DoAdd(Type, ALine, nb::bind(&TSessionLog::DoAddToSelf, this));
      }
    }
    catch (Exception &E)
    {
      // We failed logging, turn it off and notify user.
      FConfiguration->SetLogging(false);
      try
      {
        throw ExtException(&E, LoadStr(LOG_GEN_ERROR));
      }
      catch (Exception &E2)
      {
        AddException(&E2);
        FUI->HandleExtendedException(&E2);
      }
    }
  }
}
//---------------------------------------------------------------------
void TConfiguration::SetLogging(bool Value)
{
  if (GetLogging() != Value)
  {
    FPermanentLogging = Value;
    FLogging = Value;
    UpdateActualLogProtocol();
    Changed();
  }
}
Beispiel #3
0
//---------------------------------------------------------------------------
void TSessionLog::AddStartupInfo(bool System)
{
  TSessionData * Data = (System ? nullptr : FSessionData);
  if (GetLogging())
  {
    if (FParent != nullptr)
    {
      // do not add session info for secondary session
      // (this should better be handled in the TSecondaryTerminal)
    }
    else
    {
      DoAddStartupInfo(Data);
    }
  }
}
Beispiel #4
0
//---------------------------------------------------------------------------
void TSessionLog::Add(TLogLineType Type, const UnicodeString & Line)
{
  assert(FConfiguration);
  if (GetLogging())
  {
    try
    {
      if (FParent != nullptr)
      {
        DoAdd(Type, Line, MAKE_CALLBACK(TSessionLog::DoAddToParent, this));
      }
      else
      {
        TGuard Guard(FCriticalSection);

        BeginUpdate();
        auto cleanup = finally([&]()
        {
          DeleteUnnecessary();
          EndUpdate();
        });
        {
          DoAdd(Type, Line, MAKE_CALLBACK(TSessionLog::DoAddToSelf, this));
        }
      }
    }
    catch (Exception &E)
    {
      // We failed logging, turn it off and notify user.
      FConfiguration->SetLogging(false);
      try
      {
        throw ExtException(&E, LoadStr(LOG_GEN_ERROR));
      }
      catch (Exception &E)
      {
        AddException(&E);
        FUI->HandleExtendedException(&E);
      }
    }
  }
}
Beispiel #5
0
//---------------------------------------------------------------------------
void TSessionLog::DeleteUnnecessary()
{
  BeginUpdate();
  auto cleanup = finally([&]()
  {
    EndUpdate();
  });
  {
    if (!GetLogging() || (FParent != nullptr))
    {
      Clear();
    }
    else
    {
      while (!FConfiguration->GetLogWindowComplete() && (GetCount() > FConfiguration->GetLogWindowLines()))
      {
        Delete(0);
        ++FTopIndex;
      }
    }
  }
}
Beispiel #6
0
//---------------------------------------------------------------------------
bool TSessionLog::LogToFile() const
{
  return GetLogging() && FConfiguration->GetLogToFile() && (FParent == nullptr);
}