Skip to content

Commit

Permalink
Add --log option
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeMartinez committed Oct 24, 2024
1 parent fce3a36 commit 5e8867f
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 31 deletions.
23 changes: 23 additions & 0 deletions Source/CLI/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ int global::SetHash(bool Value)
return 0;
}

//---------------------------------------------------------------------------
int global::SetLogFileName(const char* FileName)
{
LogFileName = FileName;
return 0;
}

//---------------------------------------------------------------------------
int global::SetAll(bool Value)
{
Expand Down Expand Up @@ -582,6 +589,14 @@ int global::ManageCommandLine(const char* argv[], int argc)
if (Value)
return Value;
}
else if (strcmp(argv[i], "--log") == 0)
{
if (i + 1 == argc)
return Error_Missing(argv[i]);
int Value = SetLogFileName(argv[++i]);
if (Value)
return Value;
}
else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
{
int Value = Help(argv[0]);
Expand Down Expand Up @@ -815,9 +830,15 @@ int global::ManageCommandLine(const char* argv[], int argc)
return Value;
}
else
{
Inputs.push_back(argv[i]);
Inputs_Pos.insert(i);
}
}

if (BinName.empty())
BinName = "ffmpeg";

// License
if (License.LoadLicense(LicenseKey, StoreLicenseKey))
return true;
Expand All @@ -834,6 +855,8 @@ int global::ManageCommandLine(const char* argv[], int argc)
if (Inputs.empty() && (ShowLicenseKey || SubLicenseId))
return 0;

if (!LogFileName.empty())
Log = new string;
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions Source/CLI/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Lib/Uncompressed/HashSum/HashSum.h"
#include "Lib/License/License.h"
#include <map>
#include <set>
#include <vector>
#include <string>
#include <thread>
Expand All @@ -34,6 +35,7 @@ class global
string rawcooked_reversibility_FileName;
string OutputFileName;
string FrameMd5FileName;
string LogFileName;
string BinName;
string LicenseKey;
uint64_t SubLicenseId;
Expand All @@ -52,11 +54,13 @@ class global
// Intermediate info
size_t Path_Pos_Global;
vector<string> Inputs;
set<int> Inputs_Pos;
license License;
user_mode Mode = Ask;
hashes Hashes;
errors Errors;
ask_callback Ask_Callback = nullptr;
string* Log = nullptr;

// Conformance check intermediary info
vector<double> Durations;
Expand Down Expand Up @@ -100,6 +104,7 @@ class global
int SetFrameMd5An(bool Value);
int SetFrameMd5FileName(const char* FileName);
int SetHash(bool Value);
int SetLogFileName(const char* FileName);
int SetAll(bool Value);

private:
Expand Down
12 changes: 12 additions & 0 deletions Source/CLI/Help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,15 @@ ReturnValue Version()

return ReturnValue_OK;
}

//---------------------------------------------------------------------------
const char* GetLibraryName()
{
return LibraryName;
}

//---------------------------------------------------------------------------
const char* GetLibraryVersion()
{
return LibraryVersion;
}
2 changes: 2 additions & 0 deletions Source/CLI/Help.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
ReturnValue Help(const char* Name);
ReturnValue Usage(const char* Name);
ReturnValue Version();
const char* GetLibraryVersion();
const char* GetLibraryName();

#endif
Loading

0 comments on commit 5e8867f

Please sign in to comment.