Skip to content

Commit

Permalink
Add --log option
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeMartinez committed Nov 11, 2024
1 parent fce3a36 commit 9ad1391
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 32 deletions.
27 changes: 27 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,16 @@ int global::ManageCommandLine(const char* argv[], int argc)
if (Value)
return Value;
}
else if (strcmp(argv[i], "--log-name") == 0)
{
LogFile_IgnorePos.insert(i);
if (i + 1 == argc)
return Error_Missing(argv[i]);
int Value = SetLogFileName(argv[++i]);
LogFile_IgnorePos.insert(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 @@ -780,6 +797,7 @@ int global::ManageCommandLine(const char* argv[], int argc)
OutputOptions["n"] = string();
OutputOptions.erase("y");
Mode = AlwaysNo; // Also RAWcooked itself
LogFile_IgnorePos.insert(i);
}
else if (!strcmp(argv[i], "-threads"))
{
Expand All @@ -793,6 +811,7 @@ int global::ManageCommandLine(const char* argv[], int argc)
OutputOptions["y"] = string();
OutputOptions.erase("n");
Mode = AlwaysYes; // Also RAWcooked itself
LogFile_IgnorePos.insert(i);
}
else if (OptionsForOtherFiles)
{
Expand All @@ -815,9 +834,15 @@ int global::ManageCommandLine(const char* argv[], int argc)
return Value;
}
else
{
Inputs.push_back(argv[i]);
LogFile_IgnorePos.insert(i);
}
}

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

// License
if (License.LoadLicense(LicenseKey, StoreLicenseKey))
return true;
Expand All @@ -834,6 +859,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> LogFile_IgnorePos;
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
16 changes: 16 additions & 0 deletions Source/CLI/Help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ ReturnValue Help(const char* Name)
" -n Automatic no to prompts.\n"
" Assume no as answer to all prompts, and run non-interactively.\n"
"\n"
" --log-name value\n"
" Set the name of the RAWcooked log file written after\n"
" successful processing.\n"
"\n"
" ACTIONS\n"
" --all Same as --info --conch --decode --encode --hash --coherency\n"
" --check-padding --check --accept-gaps (see below)\n"
Expand Down Expand Up @@ -385,3 +389,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 9ad1391

Please sign in to comment.