Skip to content
This repository was archived by the owner on Jul 11, 2022. It is now read-only.

Commit 399d2d8

Browse files
committed
Move to new structured logging API
Resolves: #40
1 parent ef191e4 commit 399d2d8

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

Plugin/Commands.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ void Commands::analyzeStructures(BinaryViewRef bv)
3737

3838
InfoHandler::applyInfoToView(info, bv);
3939
} catch (...) {
40-
BinaryNinja::LogError("[Objective Ninja]: Error during analysis. Please report this bug!");
40+
const auto log = BinaryNinja::LogRegistry::GetLogger("ObjectiveNinja");
41+
log->LogError("Analysis failed. Please report this bug!");
4142
}
4243

4344
GlobalState::setFlag(bv, Flag::DidRunWorkflow);

Plugin/Plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ BINARYNINJAPLUGIN bool CorePluginInit()
2323
Workflow::registerActivities();
2424
Commands::registerCommands();
2525

26-
BinaryNinja::LogInfo("Objective Ninja loaded successfully (%s-%s/%s)",
26+
const auto log = BinaryNinja::LogRegistry::CreateLogger("ObjectiveNinja");
27+
log->LogInfo("Plugin loaded successfully (%s-%s/%s)",
2728
GitBranch, GitCommit, BuildType);
2829

2930
return true;

Plugin/Workflow/Workflow.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,12 @@ void Workflow::inlineMethodCalls(AnalysisContextRef ac)
126126
if (GlobalState::viewIsIgnored(bv))
127127
return;
128128

129+
const auto log = BinaryNinja::LogRegistry::GetLogger("ObjectiveNinja");
130+
129131
// Ignore the view if it has an unsupported architecture.
130132
auto archName = arch->GetName();
131133
if (archName != "aarch64" && archName != "x86_64") {
132-
BinaryNinja::LogError("Architecture '%s' not supported by Objective Ninja",
133-
archName.c_str());
134+
log->LogError("Architecture '%s' is not supported", archName.c_str());
134135
GlobalState::addIgnoredView(bv);
135136
return;
136137
}
@@ -153,7 +154,7 @@ void Workflow::inlineMethodCalls(AnalysisContextRef ac)
153154

154155
InfoHandler::applyInfoToView(info, bv);
155156
} catch (...) {
156-
BinaryNinja::LogError("[Objective Ninja]: Error during analysis. Please report this bug!");
157+
log->LogError("Analysis failed. Please report this bug!");
157158
}
158159

159160
GlobalState::setFlag(bv, Flag::DidRunStructureAnalysis);
@@ -167,19 +168,19 @@ void Workflow::inlineMethodCalls(AnalysisContextRef ac)
167168
// repeatedly search for all the usable function addresses.
168169
const auto msgSendFunctions = findMsgSendFunctions(bv);
169170
if (msgSendFunctions.empty()) {
170-
BinaryNinja::LogError("Cannot perform Objective-C IL cleanup; no objc_msgSend candidates found");
171+
log->LogError("Cannot perform Objective-C IL cleanup; no objc_msgSend candidates found");
171172
GlobalState::addIgnoredView(bv);
172173
return;
173174
}
174175

175176
const auto llil = ac->GetLowLevelILFunction();
176177
if (!llil) {
177-
BinaryNinja::LogError("Bad result from `ac->GetLowLevelILFunction()`");
178+
log->LogError("(Workflow) Failed to get LLIL for 0x%llx", func->GetStart());
178179
return;
179180
}
180181
const auto ssa = llil->GetSSAForm();
181182
if (!ssa) {
182-
BinaryNinja::LogError("Bad result from `llil->GetSSAForm()`");
183+
log->LogError("(Workflow) Failed to get LLIL SSA form for 0x%llx", func->GetStart());
183184
return;
184185
}
185186

0 commit comments

Comments
 (0)