-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add breadcrumbs automatically when printing to logs (#522)
* Add breadcrumbs automatically when printing to logs * Update package snapshot * Update changelog * Add missing include
- Loading branch information
1 parent
ae5ea63
commit 5f5234f
Showing
8 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) 2024 Sentry. All Rights Reserved. | ||
|
||
#include "SentryOutputDevice.h" | ||
|
||
#include "SentryBreadcrumb.h" | ||
#include "SentryModule.h" | ||
#include "SentrySettings.h" | ||
#include "SentrySubsystem.h" | ||
|
||
#include "Engine/Engine.h" | ||
|
||
void FSentryOutputDevice::Serialize(const TCHAR* V, ELogVerbosity::Type Verbosity, const FName& Category) | ||
{ | ||
const USentrySettings* Settings = FSentryModule::Get().GetSettings(); | ||
|
||
bool bAddBreadcrumb; | ||
|
||
ESentryLevel BreadcrumbLevel = ESentryLevel::Debug; | ||
|
||
switch (Verbosity) | ||
{ | ||
case ELogVerbosity::Fatal: | ||
bAddBreadcrumb = Settings->AutomaticBreadcrumbsForLogs.bOnFatalLog; | ||
BreadcrumbLevel = ESentryLevel::Fatal; | ||
break; | ||
case ELogVerbosity::Error: | ||
bAddBreadcrumb = Settings->AutomaticBreadcrumbsForLogs.bOnErrorLog; | ||
BreadcrumbLevel = ESentryLevel::Error; | ||
break; | ||
case ELogVerbosity::Warning: | ||
bAddBreadcrumb = Settings->AutomaticBreadcrumbsForLogs.bOnWarningLog; | ||
BreadcrumbLevel = ESentryLevel::Warning; | ||
break; | ||
case ELogVerbosity::Display: | ||
case ELogVerbosity::Log: | ||
bAddBreadcrumb = Settings->AutomaticBreadcrumbsForLogs.bOnInfoLog; | ||
BreadcrumbLevel = ESentryLevel::Info; | ||
break; | ||
case ELogVerbosity::Verbose: | ||
case ELogVerbosity::VeryVerbose: | ||
bAddBreadcrumb = Settings->AutomaticBreadcrumbsForLogs.bOnDebugLog; | ||
BreadcrumbLevel = ESentryLevel::Debug; | ||
break; | ||
default: | ||
bAddBreadcrumb = false; | ||
} | ||
|
||
if(!bAddBreadcrumb) | ||
{ | ||
return; | ||
} | ||
|
||
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>(); | ||
if(!SentrySubsystem || !SentrySubsystem->IsEnabled()) | ||
{ | ||
return; | ||
} | ||
|
||
SentrySubsystem->AddBreadcrumbWithParams(V, Category.ToString(), FString(), TMap<FString, FString>(), BreadcrumbLevel); | ||
} | ||
|
||
bool FSentryOutputDevice::CanBeUsedOnAnyThread() const | ||
{ | ||
return true; | ||
} | ||
|
||
bool FSentryOutputDevice::CanBeUsedOnMultipleThreads() const | ||
{ | ||
return true; | ||
} | ||
|
||
bool FSentryOutputDevice::CanBeUsedOnPanicThread() const | ||
{ | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2024 Sentry. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include "Misc/OutputDevice.h" | ||
|
||
class FSentryOutputDevice : public FOutputDevice | ||
{ | ||
public: | ||
virtual void Serialize( const TCHAR* V, ELogVerbosity::Type Verbosity, const FName& Category) override; | ||
|
||
virtual bool CanBeUsedOnAnyThread() const override; | ||
virtual bool CanBeUsedOnMultipleThreads() const override; | ||
virtual bool CanBeUsedOnPanicThread() const override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters