Skip to content

Commit 9b9f78a

Browse files
Add --log option
1 parent fce3a36 commit 9b9f78a

File tree

6 files changed

+262
-31
lines changed

6 files changed

+262
-31
lines changed

Source/CLI/Global.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ int global::SetHash(bool Value)
242242
return 0;
243243
}
244244

245+
//---------------------------------------------------------------------------
246+
int global::SetLogFileName(const char* FileName)
247+
{
248+
LogFileName = FileName;
249+
return 0;
250+
}
251+
245252
//---------------------------------------------------------------------------
246253
int global::SetAll(bool Value)
247254
{
@@ -582,6 +589,16 @@ int global::ManageCommandLine(const char* argv[], int argc)
582589
if (Value)
583590
return Value;
584591
}
592+
else if (strcmp(argv[i], "--log") == 0)
593+
{
594+
LogFile_IgnorePos.insert(i);
595+
if (i + 1 == argc)
596+
return Error_Missing(argv[i]);
597+
int Value = SetLogFileName(argv[++i]);
598+
LogFile_IgnorePos.insert(i);
599+
if (Value)
600+
return Value;
601+
}
585602
else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
586603
{
587604
int Value = Help(argv[0]);
@@ -815,9 +832,15 @@ int global::ManageCommandLine(const char* argv[], int argc)
815832
return Value;
816833
}
817834
else
835+
{
818836
Inputs.push_back(argv[i]);
837+
LogFile_IgnorePos.insert(i);
838+
}
819839
}
820840

841+
if (BinName.empty())
842+
BinName = "ffmpeg";
843+
821844
// License
822845
if (License.LoadLicense(LicenseKey, StoreLicenseKey))
823846
return true;
@@ -834,6 +857,8 @@ int global::ManageCommandLine(const char* argv[], int argc)
834857
if (Inputs.empty() && (ShowLicenseKey || SubLicenseId))
835858
return 0;
836859

860+
if (!LogFileName.empty())
861+
Log = new string;
837862
return 0;
838863
}
839864

Source/CLI/Global.h

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Lib/Uncompressed/HashSum/HashSum.h"
1616
#include "Lib/License/License.h"
1717
#include <map>
18+
#include <set>
1819
#include <vector>
1920
#include <string>
2021
#include <thread>
@@ -34,6 +35,7 @@ class global
3435
string rawcooked_reversibility_FileName;
3536
string OutputFileName;
3637
string FrameMd5FileName;
38+
string LogFileName;
3739
string BinName;
3840
string LicenseKey;
3941
uint64_t SubLicenseId;
@@ -52,11 +54,13 @@ class global
5254
// Intermediate info
5355
size_t Path_Pos_Global;
5456
vector<string> Inputs;
57+
set<int> LogFile_IgnorePos;
5558
license License;
5659
user_mode Mode = Ask;
5760
hashes Hashes;
5861
errors Errors;
5962
ask_callback Ask_Callback = nullptr;
63+
string* Log = nullptr;
6064

6165
// Conformance check intermediary info
6266
vector<double> Durations;
@@ -100,6 +104,7 @@ class global
100104
int SetFrameMd5An(bool Value);
101105
int SetFrameMd5FileName(const char* FileName);
102106
int SetHash(bool Value);
107+
int SetLogFileName(const char* FileName);
103108
int SetAll(bool Value);
104109

105110
private:

Source/CLI/Help.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,15 @@ ReturnValue Version()
385385

386386
return ReturnValue_OK;
387387
}
388+
389+
//---------------------------------------------------------------------------
390+
const char* GetLibraryName()
391+
{
392+
return LibraryName;
393+
}
394+
395+
//---------------------------------------------------------------------------
396+
const char* GetLibraryVersion()
397+
{
398+
return LibraryVersion;
399+
}

Source/CLI/Help.h

+2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
ReturnValue Help(const char* Name);
1818
ReturnValue Usage(const char* Name);
1919
ReturnValue Version();
20+
const char* GetLibraryVersion();
21+
const char* GetLibraryName();
2022

2123
#endif

0 commit comments

Comments
 (0)