Replaced wxLog with spdlog for logging, add spdlog dependency to README.

This commit is contained in:
apoorv569 2021-11-06 18:28:16 +05:30
parent 202cb1e7d8
commit 8bfb8c718a
12 changed files with 469 additions and 372 deletions

View File

@ -48,13 +48,13 @@ SampleHive let's you manage your audio samples in a nice and simple way, just ad
On Arch based distributions, On Arch based distributions,
#+begin_example #+begin_example
sudo pacman -S wxgtk3 wxsvg sqlite taglib yaml-cpp libsndfile sudo pacman -S wxgtk3 wxsvg sqlite taglib yaml-cpp libsndfile spdlog
#+end_example #+end_example
On Debian, Ubuntu and distributions based the on two, On Debian, Ubuntu and distributions based the on two,
#+begin_example #+begin_example
sudo apt install libwxbase3.0-dev libwxgtk-media3.0-gtk3-dev libwxgtk3.0-gtk3-dev wx3.0-headers libsqlite3-dev libyaml-cpp-dev libtagc0-dev libtag1-dev libtagc0 libexif-dev libpango1.0-dev libsndfile1-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev sudo apt install libwxbase3.0-dev libwxgtk-media3.0-gtk3-dev libwxgtk3.0-gtk3-dev wx3.0-headers libsqlite3-dev libyaml-cpp-dev libtagc0-dev libtag1-dev libtagc0 libexif-dev libpango1.0-dev libsndfile1-dev libspdlog-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev
#+end_example #+end_example
You might also need to install =git=, =cmake=, =meson= and =g++= as well, if you don't already have them installed in order to build SampleHive. You might also need to install =git=, =cmake=, =meson= and =g++= as well, if you don't already have them installed in order to build SampleHive.

View File

@ -126,6 +126,7 @@ src = [
'src/Utility/Serialize.cpp', 'src/Utility/Serialize.cpp',
'src/Utility/Tags.cpp', 'src/Utility/Tags.cpp',
'src/Utility/SH_Event.cpp', 'src/Utility/SH_Event.cpp',
'src/Utility/Log.cpp',
] ]
@ -189,6 +190,17 @@ if not snd.found()
snd = snd_subproject.dependency('sndfile') snd = snd_subproject.dependency('sndfile')
endif endif
spdlog = dependency('spdlog', version: '>=1.8.5', required: false)
if not spdlog.found()
spdlog_subproject = subproject('spdlog',
default_options: [
'default_library=static',
'compile_library=true',])
spdlog = spdlog_subproject.get_variable('spdlog_dep')
endif
# Create samplehive-config.h based on configuration # Create samplehive-config.h based on configuration
config_h = configure_file(output: 'SampleHiveConfig.hpp', config_h = configure_file(output: 'SampleHiveConfig.hpp',
configuration: config_data,) configuration: config_data,)
@ -204,14 +216,14 @@ if wx_found
cpp_args: [wx_cxx_flags], cpp_args: [wx_cxx_flags],
link_args: [wx_libs], link_args: [wx_libs],
include_directories : include_dirs, include_directories : include_dirs,
dependencies: [wx, taglib, sqlite3, yaml, snd], dependencies: [wx, taglib, sqlite3, yaml, snd, spdlog],
install: true, install: true,
install_rpath: prefix / 'lib') install_rpath: prefix / 'lib')
else else
executable('SampleHive', executable('SampleHive',
sources: src, sources: src,
include_directories : include_dirs, include_directories : include_dirs,
dependencies: [wx, taglib, sqlite3, yaml, snd], dependencies: [wx, taglib, sqlite3, yaml, snd, spdlog],
install: true, install: true,
install_rpath: prefix / 'lib') install_rpath: prefix / 'lib')
endif endif

View File

@ -20,6 +20,7 @@
#include "App.hpp" #include "App.hpp"
#include "SampleHiveConfig.hpp" #include "SampleHiveConfig.hpp"
#include "Utility/Log.hpp"
#include <wx/bitmap.h> #include <wx/bitmap.h>
#include <wx/defs.h> #include <wx/defs.h>
@ -93,5 +94,5 @@ bool App::OnCmdLineParsed(wxCmdLineParser& parser)
void App::OnEventLoopEnter(wxEventLoopBase* event) void App::OnEventLoopEnter(wxEventLoopBase* event)
{ {
if (m_Frame->CreateWatcherIfNecessary()) if (m_Frame->CreateWatcherIfNecessary())
wxLogDebug("Filesystem watcher created sucessfully"); SH_LOG_INFO("Filesystem watcher created sucessfully");
} }

View File

@ -19,6 +19,7 @@
*/ */
#include "Database/Database.hpp" #include "Database/Database.hpp"
#include "Utility/Log.hpp"
#include <deque> #include <deque>
#include <exception> #include <exception>
@ -26,7 +27,6 @@
#include <wx/dataview.h> #include <wx/dataview.h>
#include <wx/dvrenderers.h> #include <wx/dvrenderers.h>
#include <wx/log.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/stringimpl.h> #include <wx/stringimpl.h>
@ -48,14 +48,15 @@ void debug_log_on_error(int rc)
} }
} }
void show_modal_dialog_and_log(const std::string &message, const std::string &title, const std::string &error_msg) void show_modal_dialog_and_log(const std::string &message, const std::string &title,
const std::string &error_msg)
{ {
std::stringstream ss; std::stringstream ss;
ss << message << error_msg; ss << message << error_msg;
const auto msg = ss.str(); const auto msg = ss.str();
wxLogDebug(msg.c_str()); SH_LOG_ERROR(msg.c_str());
wxMessageDialog msgDialog(NULL, _(msg), _(title), wxOK | wxICON_ERROR); wxMessageDialog msgDialog(NULL, _(msg), _(title), wxOK | wxICON_ERROR);
msgDialog.ShowModal(); msgDialog.ShowModal();
@ -73,7 +74,7 @@ class Sqlite3Statement
throw_on_sqlite3_error(sqlite3_finalize(stmt)); throw_on_sqlite3_error(sqlite3_finalize(stmt));
} }
sqlite3_stmt *stmt = nullptr; sqlite3_stmt* stmt = nullptr;
}; };
Database::Database(const std::string &dbPath) Database::Database(const std::string &dbPath)
@ -106,11 +107,11 @@ void Database::CreateTableSamples()
try try
{ {
throw_on_sqlite3_error(sqlite3_exec(m_Database, samples, NULL, 0, &m_ErrMsg)); throw_on_sqlite3_error(sqlite3_exec(m_Database, samples, NULL, 0, &m_ErrMsg));
wxLogDebug(_("Samples table created successfully.")); SH_LOG_INFO("SAMPLES table created successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot create table samples: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot create SAMPLES table", "Error", e.what());
} }
} }
@ -122,11 +123,11 @@ void Database::CreateTableHives()
try try
{ {
throw_on_sqlite3_error(sqlite3_exec(m_Database, hives, NULL, 0, &m_ErrMsg)); throw_on_sqlite3_error(sqlite3_exec(m_Database, hives, NULL, 0, &m_ErrMsg));
wxLogDebug("Hives table created successfully."); SH_LOG_INFO("HIVES table created successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot create hives table", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot create HIVES table", "Error", e.what());
} }
} }
@ -165,17 +166,23 @@ void Database::InsertIntoSamples(const std::vector<Sample> &samples)
std::string hive = "Favorites"; std::string hive = "Favorites";
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, sample.GetFavorite())); throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, sample.GetFavorite()));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 3, file_extension.c_str(), file_extension.size(), SQLITE_STATIC)); filename.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 4, sample_pack.c_str(), sample_pack.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 3, file_extension.c_str(),
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 5, type.c_str(), type.size(), SQLITE_STATIC)); file_extension.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 4, sample_pack.c_str(),
sample_pack.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 5, type.c_str(),
type.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 6, sample.GetChannels())); throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 6, sample.GetChannels()));
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 7, sample.GetLength())); throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 7, sample.GetLength()));
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 8, sample.GetSampleRate())); throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 8, sample.GetSampleRate()));
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 9, sample.GetBitrate())); throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 9, sample.GetBitrate()));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 10, path.c_str(), path.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 10, path.c_str(),
path.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 11, sample.GetTrashed())); throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 11, sample.GetTrashed()));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 12, hive.c_str(), hive.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 12, hive.c_str(),
hive.size(), SQLITE_STATIC));
sqlite3_step(statement.stmt); sqlite3_step(statement.stmt);
throw_on_sqlite3_error(sqlite3_clear_bindings(statement.stmt)); throw_on_sqlite3_error(sqlite3_clear_bindings(statement.stmt));
@ -184,11 +191,11 @@ void Database::InsertIntoSamples(const std::vector<Sample> &samples)
throw_on_sqlite3_error(sqlite3_exec(m_Database, "END TRANSACTION", NULL, NULL, &m_ErrMsg)); throw_on_sqlite3_error(sqlite3_exec(m_Database, "END TRANSACTION", NULL, NULL, &m_ErrMsg));
wxLogDebug("Data inserted successfully."); SH_LOG_INFO("Data inserted successfully into SAMPLES.");
} }
catch (const std::exception &exception) catch (const std::exception &e)
{ {
wxLogDebug(exception.what()); show_modal_dialog_and_log("Error! Cannot insert data into SAMPLES", "Error", e.what());
} }
} }
@ -223,7 +230,8 @@ void Database::InsertIntoHives(const std::string &hiveName)
// std::string hive = "Favourites"; // std::string hive = "Favourites";
// rc = sqlite3_bind_int(statement.stmt, 1, sample.GetFavorite()); // rc = sqlite3_bind_int(statement.stmt, 1, sample.GetFavorite());
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(),
hiveName.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_step(statement.stmt)); throw_on_sqlite3_error(sqlite3_step(statement.stmt));
// rc = sqlite3_clear_bindings(statement.stmt); // rc = sqlite3_clear_bindings(statement.stmt);
@ -232,11 +240,11 @@ void Database::InsertIntoHives(const std::string &hiveName)
// rc = sqlite3_exec(m_Database, "END TRANSACTION", NULL, NULL, &m_ErrMsg); // rc = sqlite3_exec(m_Database, "END TRANSACTION", NULL, NULL, &m_ErrMsg);
wxLogDebug("Data inserted successfully."); SH_LOG_INFO("Data inserted successfully into HIVES.");
} }
catch (const std::exception &exception) catch (const std::exception &e)
{ {
wxLogDebug(exception.what()); show_modal_dialog_and_log("Error! Cannot insert data into HIVES", "Error", e.what());
} }
} }
@ -248,21 +256,23 @@ void Database::UpdateHive(const std::string &hiveOldName, const std::string &hiv
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveNewName.c_str(), hiveNewName.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveNewName.c_str(),
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, hiveOldName.c_str(), hiveOldName.size(), SQLITE_STATIC)); hiveNewName.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, hiveOldName.c_str(),
hiveOldName.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) != SQLITE_DONE) if (sqlite3_step(statement.stmt) != SQLITE_DONE)
{ {
wxLogWarning("No data inserted."); SH_LOG_INFO("Updating hive {} to {}", hiveOldName, hiveNewName);
} }
else else
{ {
wxLogDebug("Hive updated successfully. %s", m_ErrMsg); SH_LOG_INFO("Updated hive successfully.");
} }
} }
catch (const std::exception &exception) catch (const std::exception& e)
{ {
wxLogDebug(exception.what()); show_modal_dialog_and_log("Error! Cannot update hive", "Error", e.what());
} }
} }
@ -274,19 +284,21 @@ void Database::UpdateHiveName(const std::string &filename, const std::string &hi
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(),
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC)); hiveName.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, updating.."); SH_LOG_INFO("Updating hive to {} for {}", hiveName, filename);
} }
wxLogDebug("Updated record successfully."); SH_LOG_INFO("Updated hive name successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot update record: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot update hive name", "Error", e.what());
} }
} }
@ -299,18 +311,19 @@ void Database::UpdateFavoriteColumn(const std::string &filename, int value)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value)); throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, updating.."); SH_LOG_INFO("Updating favorite value of {} to {}", filename, value);
} }
wxLogDebug("Updated record successfully."); SH_LOG_INFO("Updated favorite column successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot update record: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot update favorite column", "Error", e.what());
} }
} }
@ -322,19 +335,21 @@ void Database::UpdateSamplePack(const std::string &filename, const std::string &
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, samplePack.c_str(), samplePack.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, samplePack.c_str(),
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC)); samplePack.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, updating.."); SH_LOG_INFO("Updating sample pack of {} to {}", filename, samplePack);
} }
wxLogDebug("Updated record successfully."); SH_LOG_INFO("Updated sample pack successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot update record: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot update sample pack", "Error", e.what());
} }
} }
@ -347,17 +362,19 @@ void Database::UpdateSampleType(const std::string &filename, const std::string &
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, type.c_str(), type.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, type.c_str(), type.size(), SQLITE_STATIC));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, updating.."); SH_LOG_INFO("Updating sample type of {} to {}", filename, type);
} }
wxLogDebug("Updated record successfully.");
SH_LOG_INFO("Updated sample type successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot update record: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot update sample type", "Error", e.what());
} }
} }
@ -371,20 +388,21 @@ std::string Database::GetSampleType(const std::string &filename)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, fetching.."); SH_LOG_INFO("Record found, fetching sample type for {}", filename);
type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0))); type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
} }
wxLogDebug("Selected data from table successfully."); SH_LOG_INFO("Selected sample type from table successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot get sample type column value from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot get sample type from table", "Error", e.what());
} }
return type; return type;
@ -400,19 +418,20 @@ int Database::GetFavoriteColumnValueByFilename(const std::string &filename)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, fetching..");
value = sqlite3_column_int(statement.stmt, 0); value = sqlite3_column_int(statement.stmt, 0);
SH_LOG_INFO("Record found, fetching favorite column value for {}", filename);
} }
wxLogDebug("Selected data from table successfully."); SH_LOG_INFO("Selected favorite column from table successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot get favorite column value from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot get favorite column value from table", "Error", e.what());
} }
return value; return value;
@ -428,19 +447,20 @@ std::string Database::GetHiveByFilename(const std::string &filename)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, fetching..");
hive = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0))); hive = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
SH_LOG_INFO("Record found, fetching hive for {}", filename);
} }
wxLogDebug("Selected data from table successfully."); SH_LOG_INFO("Selected hive from table successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot get hive value from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot get hive value from table", "Error", e.what());
} }
return hive; return hive;
@ -454,18 +474,19 @@ void Database::RemoveSampleFromDatabase(const std::string &filename)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_DONE) if (sqlite3_step(statement.stmt) == SQLITE_DONE)
{ {
wxLogDebug("Record found, Deleting.."); SH_LOG_INFO("Record found, Deleting {} from table", filename);
} }
wxLogDebug("Deleted data from table successfully."); SH_LOG_INFO("Deleted sample from table successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot get hive value from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot delete sample from table", "Error", e.what());
} }
} }
@ -477,18 +498,19 @@ void Database::RemoveHiveFromDatabase(const std::string &hiveName)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(),
hiveName.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_DONE) if (sqlite3_step(statement.stmt) == SQLITE_DONE)
{ {
wxLogDebug("Record found, Deleting.."); SH_LOG_INFO("Record found, Deleting hive {} from table", hiveName);
} }
wxLogDebug("Deleted data from table successfully."); SH_LOG_INFO("Deleted hive from table successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot get hive value from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot delete hive from table", "Error", e.what());
} }
} }
@ -502,19 +524,20 @@ std::string Database::GetSamplePathByFilename(const std::string &filename)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, fetching..");
path = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0))); path = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
SH_LOG_INFO("Record found, fetching sample path for {}", filename);
} }
wxLogDebug("Selected data from table successfully."); SH_LOG_INFO("Selected sample path from table successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot select sample path from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot select sample path from table", "Error", e.what());
} }
return path; return path;
@ -530,19 +553,20 @@ std::string Database::GetSampleFileExtension(const std::string &filename)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogInfo("Record found, fetching..");
extension = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0))); extension = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
SH_LOG_INFO("Record found, fetching file extension for {}", filename);
} }
wxLogDebug("Selected data from table successfully."); SH_LOG_INFO("Selected file extension from table successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot select sample extension from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot select sample extension from table", "Error", e.what());
} }
return extension; return extension;
@ -571,7 +595,7 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
{ {
num_rows = sqlite3_column_int(statement1.stmt, 0); num_rows = sqlite3_column_int(statement1.stmt, 0);
wxLogDebug("Loading %d samples..", num_rows); SH_LOG_INFO("Loading {} samples..", num_rows);
vecSet.reserve(num_rows); vecSet.reserve(num_rows);
} }
@ -585,17 +609,23 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
while (SQLITE_ROW == sqlite3_step(statement.stmt)) while (SQLITE_ROW == sqlite3_step(statement.stmt))
{ {
int favorite = sqlite3_column_int(statement.stmt, 0); int favorite = sqlite3_column_int(statement.stmt, 0);
wxString filename = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 1))); wxString filename = std::string(reinterpret_cast<const char *>
wxString file_extension = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 2))); (sqlite3_column_text(statement.stmt, 1)));
wxString sample_pack = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 3))); wxString file_extension = std::string(reinterpret_cast<const char *>
wxString sample_type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 4))); (sqlite3_column_text(statement.stmt, 2)));
wxString sample_pack = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 3)));
wxString sample_type = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 4)));
int channels = sqlite3_column_int(statement.stmt, 5); int channels = sqlite3_column_int(statement.stmt, 5);
int length = sqlite3_column_int(statement.stmt, 6); int length = sqlite3_column_int(statement.stmt, 6);
int sample_rate = sqlite3_column_int(statement.stmt, 7); int sample_rate = sqlite3_column_int(statement.stmt, 7);
int bitrate = sqlite3_column_int(statement.stmt, 8); int bitrate = sqlite3_column_int(statement.stmt, 8);
wxString path = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 9))); wxString path = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 9)));
int trashed = sqlite3_column_int(statement.stmt, 10); int trashed = sqlite3_column_int(statement.stmt, 10);
wxString hive_name = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 11))); wxString hive_name = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 11)));
wxLongLong llLength = length; wxLongLong llLength = length;
int total_min = static_cast<int>((llLength / 60000).GetValue()); int total_min = static_cast<int>((llLength / 60000).GetValue());
@ -615,7 +645,6 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
{ {
if (favorite == 1) if (favorite == 1)
{ {
// vec.push_back(true);
vec.push_back(icon_filled); vec.push_back(icon_filled);
std::deque<wxDataViewItem> nodes; std::deque<wxDataViewItem> nodes;
@ -687,7 +716,7 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot load data from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot load data from SAMPLES", "Error", e.what());
} }
return vecSet; return vecSet;
@ -709,22 +738,28 @@ Database::FilterDatabaseBySampleName(const std::string &sampleName, bool show_ex
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \ CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
FROM SAMPLES WHERE FILENAME LIKE '%' || ? || '%' ;"); FROM SAMPLES WHERE FILENAME LIKE '%' || ? || '%' ;");
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, sampleName.c_str(), sampleName.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, sampleName.c_str(),
sampleName.size(), SQLITE_STATIC));
int row = 0; int row = 0;
while (SQLITE_ROW == sqlite3_step(statement.stmt)) while (SQLITE_ROW == sqlite3_step(statement.stmt))
{ {
wxLogDebug("Record found, fetching.."); SH_LOG_INFO("Record found, filtering db by {}", sampleName);
int favorite = sqlite3_column_int(statement.stmt, 0); int favorite = sqlite3_column_int(statement.stmt, 0);
wxString filename = wxString(std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 1)))); wxString filename = wxString(std::string(reinterpret_cast<const char *>
wxString sample_pack = wxString(std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 2)))); (sqlite3_column_text(statement.stmt, 1))));
wxString sample_type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 3))); wxString sample_pack = wxString(std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 2))));
wxString sample_type = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 3)));
int channels = sqlite3_column_int(statement.stmt, 4); int channels = sqlite3_column_int(statement.stmt, 4);
int length = sqlite3_column_int(statement.stmt, 5); int length = sqlite3_column_int(statement.stmt, 5);
int sample_rate = sqlite3_column_int(statement.stmt, 6); int sample_rate = sqlite3_column_int(statement.stmt, 6);
int bitrate = sqlite3_column_int(statement.stmt, 7); int bitrate = sqlite3_column_int(statement.stmt, 7);
wxString path = wxString(std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 8)))); wxString path = wxString(std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 8))));
wxLongLong llLength = length; wxLongLong llLength = length;
int total_min = static_cast<int>((llLength / 60000).GetValue()); int total_min = static_cast<int>((llLength / 60000).GetValue());
@ -761,7 +796,7 @@ Database::FilterDatabaseBySampleName(const std::string &sampleName, bool show_ex
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot filter data from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot filter data from table", "Error", e.what());
} }
return sampleVec; return sampleVec;
@ -783,22 +818,28 @@ Database::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extens
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \ CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
FROM SAMPLES WHERE HIVE = ? AND FAVORITE = 1;"); FROM SAMPLES WHERE HIVE = ? AND FAVORITE = 1;");
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(),
hiveName.size(), SQLITE_STATIC));
int row = 0; int row = 0;
while (SQLITE_ROW == sqlite3_step(statement.stmt)) while (SQLITE_ROW == sqlite3_step(statement.stmt))
{ {
wxLogDebug("Record found, fetching.."); SH_LOG_INFO("Record found, filtering db by {}", hiveName);
int favorite = sqlite3_column_int(statement.stmt, 0); int favorite = sqlite3_column_int(statement.stmt, 0);
wxString filename = wxString(std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 1)))); wxString filename = wxString(std::string(reinterpret_cast<const char *>
wxString sample_pack = wxString(std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 2)))); (sqlite3_column_text(statement.stmt, 1))));
wxString sample_type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 3))); wxString sample_pack = wxString(std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 2))));
wxString sample_type = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 3)));
int channels = sqlite3_column_int(statement.stmt, 4); int channels = sqlite3_column_int(statement.stmt, 4);
int length = sqlite3_column_int(statement.stmt, 5); int length = sqlite3_column_int(statement.stmt, 5);
int sample_rate = sqlite3_column_int(statement.stmt, 6); int sample_rate = sqlite3_column_int(statement.stmt, 6);
int bitrate = sqlite3_column_int(statement.stmt, 7); int bitrate = sqlite3_column_int(statement.stmt, 7);
wxString path = wxString(std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 8)))); wxString path = wxString(std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 8))));
wxLongLong llLength = length; wxLongLong llLength = length;
int total_min = static_cast<int>((llLength / 60000).GetValue()); int total_min = static_cast<int>((llLength / 60000).GetValue());
@ -811,21 +852,10 @@ Database::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extens
else else
vec.push_back(icon_empty); vec.push_back(icon_empty);
// if (favorite == 1)
// vec.push_back(true);
// else
// vec.push_back(false);
// vec.push_back(filename);
if (show_extension) if (show_extension)
{
vec.push_back(path.AfterLast('/')); vec.push_back(path.AfterLast('/'));
}
else else
{
vec.push_back(path.AfterLast('/').BeforeLast('.')); vec.push_back(path.AfterLast('/').BeforeLast('.'));
}
vec.push_back(sample_pack); vec.push_back(sample_pack);
vec.push_back(sample_type); vec.push_back(sample_type);
@ -842,7 +872,7 @@ Database::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extens
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot filter data from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot filter data from table", "Error", e.what());
} }
return sampleVec; return sampleVec;
@ -858,7 +888,7 @@ void Database::LoadHivesDatabase(wxDataViewTreeCtrl &treeCtrl)
while (SQLITE_ROW == sqlite3_step(statement.stmt)) while (SQLITE_ROW == sqlite3_step(statement.stmt))
{ {
wxLogDebug("Loading hives.."); SH_LOG_INFO("Loading hives..");
const auto hive = wxString(std::string(reinterpret_cast<const char *> const auto hive = wxString(std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 0)))); (sqlite3_column_text(statement.stmt, 0))));
@ -868,7 +898,7 @@ void Database::LoadHivesDatabase(wxDataViewTreeCtrl &treeCtrl)
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot load hive from hives table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot load hive from hives table", "Error", e.what());
} }
} }
@ -895,15 +925,15 @@ wxArrayString Database::CheckDuplicates(const wxArrayString &files)
if (sqlite3_step(statement.stmt) != SQLITE_ROW) if (sqlite3_step(statement.stmt) != SQLITE_ROW)
sorted_files.push_back(files[i]); sorted_files.push_back(files[i]);
else else
wxLogDebug("Already added: %s. Skipping..", files[i]); SH_LOG_INFO("Already added: {}, skipping..", files[i]);
rc = sqlite3_clear_bindings(statement.stmt); rc = sqlite3_clear_bindings(statement.stmt);
rc = sqlite3_reset(statement.stmt); rc = sqlite3_reset(statement.stmt);
} }
} }
catch (const std::exception &exception) catch (const std::exception &e)
{ {
wxLogDebug(exception.what()); show_modal_dialog_and_log("Error! Cannot check duplicates from table", "Error", e.what());
} }
return sorted_files; return sorted_files;
@ -917,21 +947,22 @@ bool Database::IsTrashed(const std::string &filename)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, fetching.."); SH_LOG_INFO("Record found, fetching {} trash status", filename);
if (sqlite3_column_int(statement.stmt, 0) == 1) if (sqlite3_column_int(statement.stmt, 0) == 1)
return true; return true;
} }
wxLogDebug("Selected data from table successfully."); SH_LOG_INFO("Selected trash status from table successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot select sample path from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot check for trash status from table", "Error", e.what());
} }
return false; return false;
@ -946,18 +977,19 @@ void Database::UpdateTrashColumn(const std::string &filename, int value)
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value)); throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
filename.size(), SQLITE_STATIC));
if (sqlite3_step(statement.stmt) == SQLITE_ROW) if (sqlite3_step(statement.stmt) == SQLITE_ROW)
{ {
wxLogDebug("Record found, updating.."); SH_LOG_INFO("Record found, updating trash status for {}", filename);
} }
wxLogDebug("Updated record successfully."); SH_LOG_INFO("Updated trash status successfully.");
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot update record: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot update trash status", "Error", e.what());
} }
} }
@ -978,22 +1010,29 @@ Database::RestoreFromTrashByFilename(const std::string &filename,
Sqlite3Statement statement(m_Database, sql); Sqlite3Statement statement(m_Database, sql);
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC)); throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
filename.size(), SQLITE_STATIC));
while (SQLITE_ROW == sqlite3_step(statement.stmt)) while (SQLITE_ROW == sqlite3_step(statement.stmt))
{ {
int favorite = sqlite3_column_int(statement.stmt, 0); int favorite = sqlite3_column_int(statement.stmt, 0);
wxString filename = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 1))); wxString filename = std::string(reinterpret_cast<const char *>
wxString file_extension = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 2))); (sqlite3_column_text(statement.stmt, 1)));
wxString sample_pack = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 3))); wxString file_extension = std::string(reinterpret_cast<const char *>
wxString sample_type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 4))); (sqlite3_column_text(statement.stmt, 2)));
wxString sample_pack = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 3)));
wxString sample_type = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 4)));
int channels = sqlite3_column_int(statement.stmt, 5); int channels = sqlite3_column_int(statement.stmt, 5);
int length = sqlite3_column_int(statement.stmt, 6); int length = sqlite3_column_int(statement.stmt, 6);
int sample_rate = sqlite3_column_int(statement.stmt, 7); int sample_rate = sqlite3_column_int(statement.stmt, 7);
int bitrate = sqlite3_column_int(statement.stmt, 8); int bitrate = sqlite3_column_int(statement.stmt, 8);
wxString path = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 9))); wxString path = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 9)));
int trashed = sqlite3_column_int(statement.stmt, 10); int trashed = sqlite3_column_int(statement.stmt, 10);
wxString hive_name = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 11))); wxString hive_name = std::string(reinterpret_cast<const char *>
(sqlite3_column_text(statement.stmt, 11)));
wxLongLong llLength = length; wxLongLong llLength = length;
int total_min = static_cast<int>((llLength / 60000).GetValue()); int total_min = static_cast<int>((llLength / 60000).GetValue());
@ -1027,7 +1066,7 @@ Database::RestoreFromTrashByFilename(const std::string &filename,
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
show_modal_dialog_and_log("Error! Cannot load data from table: ", "Error", e.what()); show_modal_dialog_and_log("Error! Cannot restore trash data from table", "Error", e.what());
} }
return vecSet; return vecSet;

View File

@ -21,10 +21,10 @@
#include "GUI/Dialogs/Settings.hpp" #include "GUI/Dialogs/Settings.hpp"
#include "Utility/ControlID_Enums.hpp" #include "Utility/ControlID_Enums.hpp"
#include "Utility/Serialize.hpp" #include "Utility/Serialize.hpp"
#include "Utility/Log.hpp"
#include <wx/defs.h> #include <wx/defs.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/log.h>
#include <wx/stringimpl.h> #include <wx/stringimpl.h>
Settings::Settings(const std::string& configFilepath, const std::string& databaseFilepath) Settings::Settings(const std::string& configFilepath, const std::string& databaseFilepath)
@ -358,8 +358,8 @@ void Settings::OnChangeFontSize(wxSpinEvent& event)
m_Window->SetFont(m_Font); m_Window->SetFont(m_Font);
this->SetFont(m_Font); this->SetFont(m_Font);
wxLogDebug("Font size: %d", font_size); SH_LOG_DEBUG("Font size: {}", font_size);
wxLogDebug("Font size: %d", m_Font.GetPointSize()); SH_LOG_DEBUG("Font size: {}", m_Font.GetPointSize());
} }
void Settings::LoadDefaultConfig() void Settings::LoadDefaultConfig()
@ -422,11 +422,11 @@ void Settings::SetShowExtension(bool value)
void Settings::PrintFont() void Settings::PrintFont()
{ {
wxLogDebug("Font face: %s", m_Font.GetFaceName()); SH_LOG_DEBUG("Font face: {}", m_Font.GetFaceName());
wxLogDebug("Font size: %d", m_Font.GetPointSize()); SH_LOG_DEBUG("Font size: {}", m_Font.GetPointSize());
wxLogDebug("Font family: %s", m_Font.GetFamilyString()); SH_LOG_DEBUG("Font family: {}", m_Font.GetFamilyString());
wxLogDebug("Font style: %s", m_Font.GetStyleString()); SH_LOG_DEBUG("Font style: {}", m_Font.GetStyleString());
wxLogDebug("Font weight: %s", m_Font.GetWeightString()); SH_LOG_DEBUG("Font weight: {}", m_Font.GetWeightString());
} }
void Settings::SetCustomFont() void Settings::SetCustomFont()
@ -475,14 +475,14 @@ void Settings::OnChangeWaveformColour(wxColourPickerEvent& event)
if (colour != wave_colour) if (colour != wave_colour)
{ {
wxLogDebug("Waveform colour changed."); SH_LOG_INFO("Waveform colour changed.");
bWaveformColourChanged = true; bWaveformColourChanged = true;
serializer.SerializeWaveformColour(colour); serializer.SerializeWaveformColour(colour);
} }
else else
{ {
wxLogDebug("Waveform colour not changed."); SH_LOG_INFO("Waveform colour not changed.");
bWaveformColourChanged = false; bWaveformColourChanged = false;
serializer.SerializeWaveformColour(colour); serializer.SerializeWaveformColour(colour);

View File

@ -19,12 +19,12 @@
*/ */
#include "Utility/ControlID_Enums.hpp" #include "Utility/ControlID_Enums.hpp"
#include "Utility/Log.hpp"
#include "Database/Database.hpp" #include "Database/Database.hpp"
#include "GUI/Dialogs/TagEditor.hpp" #include "GUI/Dialogs/TagEditor.hpp"
#include <wx/defs.h> #include <wx/defs.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/log.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/stringimpl.h> #include <wx/stringimpl.h>
#include <wx/textdlg.h> #include <wx/textdlg.h>
@ -255,7 +255,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
case wxID_YES: case wxID_YES:
if (m_TitleCheck->GetValue() && m_TitleText->GetValue() != tags.GetAudioInfo().title) if (m_TitleCheck->GetValue() && m_TitleText->GetValue() != tags.GetAudioInfo().title)
{ {
wxLogDebug("Changing title tag.."); SH_LOG_INFO("Changing title tag..");
tags.SetTitle(title.ToStdString()); tags.SetTitle(title.ToStdString());
info_msg = wxString::Format("Successfully changed title tag to %s", title); info_msg = wxString::Format("Successfully changed title tag to %s", title);
@ -263,19 +263,19 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
if (m_ArtistCheck->GetValue() && m_ArtistText->GetValue() != tags.GetAudioInfo().artist) if (m_ArtistCheck->GetValue() && m_ArtistText->GetValue() != tags.GetAudioInfo().artist)
{ {
wxLogDebug("Changing artist tag.."); SH_LOG_INFO("Changing artist tag..");
tags.SetArtist(artist.ToStdString()); tags.SetArtist(artist.ToStdString());
db.UpdateSamplePack(m_Filename, artist.ToStdString()); db.UpdateSamplePack(m_Filename, artist.ToStdString());
wxLogDebug("SAMPLE FILENAME HERE: %s", m_Filename); SH_LOG_DEBUG("SAMPLE FILENAME HERE: %s", m_Filename);
info_msg = wxString::Format("Successfully changed artist tag to %s", artist); info_msg = wxString::Format("Successfully changed artist tag to %s", artist);
} }
if (m_AlbumCheck->GetValue() && m_AlbumText->GetValue() != tags.GetAudioInfo().album) if (m_AlbumCheck->GetValue() && m_AlbumText->GetValue() != tags.GetAudioInfo().album)
{ {
wxLogDebug("Changing album tag.."); SH_LOG_INFO("Changing album tag..");
tags.SetAlbum(album.ToStdString()); tags.SetAlbum(album.ToStdString());
info_msg = wxString::Format("Successfully changed album tag to %s", album); info_msg = wxString::Format("Successfully changed album tag to %s", album);
@ -283,7 +283,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
if (m_GenreCheck->GetValue() && m_GenreText->GetValue() != tags.GetAudioInfo().genre) if (m_GenreCheck->GetValue() && m_GenreText->GetValue() != tags.GetAudioInfo().genre)
{ {
wxLogDebug("Changing genre tag.."); SH_LOG_INFO("Changing genre tag..");
tags.SetGenre(genre.ToStdString()); tags.SetGenre(genre.ToStdString());
info_msg = wxString::Format("Successfully changed genre tag to %s", genre); info_msg = wxString::Format("Successfully changed genre tag to %s", genre);
@ -291,7 +291,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
if (m_CommentCheck->GetValue() && m_CommentText->GetValue() != tags.GetAudioInfo().comment) if (m_CommentCheck->GetValue() && m_CommentText->GetValue() != tags.GetAudioInfo().comment)
{ {
wxLogDebug("Changing comment tag.."); SH_LOG_INFO("Changing comment tag..");
tags.SetComment(comment.ToStdString()); tags.SetComment(comment.ToStdString());
info_msg = wxString::Format("Successfully changed comment tag to %s", comment); info_msg = wxString::Format("Successfully changed comment tag to %s", comment);
@ -299,7 +299,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
if (m_SampleTypeCheck->GetValue() && m_SampleTypeChoice->GetStringSelection() != sampleType) if (m_SampleTypeCheck->GetValue() && m_SampleTypeChoice->GetStringSelection() != sampleType)
{ {
wxLogDebug("Changing type tag.."); SH_LOG_INFO("Changing type tag..");
db.UpdateSampleType(filename, type.ToStdString()); db.UpdateSampleType(filename, type.ToStdString());
info_msg = wxString::Format("Successfully changed type tag to %s", type); info_msg = wxString::Format("Successfully changed type tag to %s", type);

View File

@ -25,6 +25,7 @@
#include "Utility/ControlID_Enums.hpp" #include "Utility/ControlID_Enums.hpp"
#include "Utility/Tags.hpp" #include "Utility/Tags.hpp"
#include "Utility/Sample.hpp" #include "Utility/Sample.hpp"
#include "Utility/Log.hpp"
#include "SampleHiveConfig.hpp" #include "SampleHiveConfig.hpp"
#include <algorithm> #include <algorithm>
@ -56,7 +57,6 @@
#include <wx/icon.h> #include <wx/icon.h>
#include <wx/dataobj.h> #include <wx/dataobj.h>
#include <wx/headercol.h> #include <wx/headercol.h>
#include <wx/log.h>
#include <wx/menu.h> #include <wx/menu.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/object.h> #include <wx/object.h>
@ -87,8 +87,9 @@
#define ICON_AB_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-light_16x16.png" #define ICON_AB_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-light_16x16.png"
#define ICON_LOOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-light_16x16.png" #define ICON_LOOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-light_16x16.png"
#define ICON_MUTE_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-light_16x16.png" #define ICON_MUTE_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-light_16x16.png"
#define APP_CONFIG_DIR wxGetHomeDir() + "/.config/SampleHive" #define USER_HOME_DIR wxGetUserHome()
#define APP_DATA_DIR wxGetHomeDir() + "/.local/share/SampleHive" #define APP_CONFIG_DIR USER_HOME_DIR + "/.config/SampleHive"
#define APP_DATA_DIR USER_HOME_DIR + "/.local/share/SampleHive"
#define CONFIG_FILEPATH APP_CONFIG_DIR + "/config.yaml" #define CONFIG_FILEPATH APP_CONFIG_DIR + "/config.yaml"
#define DATABASE_FILEPATH APP_DATA_DIR "/sample.hive" #define DATABASE_FILEPATH APP_DATA_DIR "/sample.hive"
@ -155,6 +156,9 @@ MainFrame::MainFrame()
// Set the menu bar to use // Set the menu bar to use
SetMenuBar(m_MenuBar); SetMenuBar(m_MenuBar);
// Initialize the logger
SampleHive::Log::InitLogger("SampleHive");
// Load default yaml config file. // Load default yaml config file.
LoadConfigFile(); LoadConfigFile();
@ -209,8 +213,7 @@ MainFrame::MainFrame()
_("All files|*|Ogg files (*.ogg)|*.ogg|Wav files (*.wav)|*.wav|" _("All files|*|Ogg files (*.ogg)|*.ogg|Wav files (*.wav)|*.wav|"
"Flac files (*.flac)|*.flac"), 0); "Flac files (*.flac)|*.flac"), 0);
wxString path = wxGetHomeDir(); m_DirCtrl->SetPath(USER_HOME_DIR);
m_DirCtrl->SetPath(path);
// This panel will hold 2nd page of wxNotebook // This panel will hold 2nd page of wxNotebook
m_HivesPanel = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); m_HivesPanel = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
@ -702,7 +705,7 @@ void MainFrame::AddSamples(wxArrayString& files)
data.push_back(wxString::Format("%d", sample.GetBitrate())); data.push_back(wxString::Format("%d", sample.GetBitrate()));
data.push_back(path); data.push_back(path);
wxLogDebug(_("Adding file: %s :: Extension: %s"), sample.GetFilename(), sample.GetFileExtension()); SH_LOG_INFO("Adding file: {}, Extension: {}", sample.GetFilename(), sample.GetFileExtension());
m_Library->AppendItem(data); m_Library->AppendItem(data);
@ -733,7 +736,7 @@ void MainFrame::OnClickDirCtrl(wxCommandEvent& event)
void MainFrame::OnDragAndDropToLibrary(wxDropFilesEvent& event) void MainFrame::OnDragAndDropToLibrary(wxDropFilesEvent& event)
{ {
wxLogDebug(_("Start Inserting Samples")); SH_LOG_DEBUG("Start Inserting Samples");
if (event.GetNumberOfFiles() > 0) if (event.GetNumberOfFiles() > 0)
{ {
@ -777,7 +780,7 @@ void MainFrame::OnDragAndDropToLibrary(wxDropFilesEvent& event)
AddSamples(filepath_array); AddSamples(filepath_array);
wxLogDebug(_("Done Inserting Samples")); SH_LOG_DEBUG("Done Inserting Samples");
} }
} }
@ -816,8 +819,7 @@ void MainFrame::OnDragAndDropToHives(wxDropFilesEvent& event)
wxString file_name = serializer.DeserializeShowFileExtensionSetting() ? wxString file_name = serializer.DeserializeShowFileExtensionSetting() ?
files[i].BeforeLast('.') : files[i]; files[i].BeforeLast('.') : files[i];
wxLogDebug(_("Dropping %d files %s on %s"), SH_LOG_DEBUG("Dropping {} file(s) {} on {}", rows - i, files[i], m_Hives->GetItemText(drop_target));
rows - i, files[i], m_Hives->GetItemText(drop_target));
if (drop_target.IsOk() && m_Hives->IsContainer(drop_target) && if (drop_target.IsOk() && m_Hives->IsContainer(drop_target) &&
m_Database->GetFavoriteColumnValueByFilename(file_name.ToStdString()) == 0) m_Database->GetFavoriteColumnValueByFilename(file_name.ToStdString()) == 0)
@ -859,7 +861,7 @@ void MainFrame::OnDragAndDropToHives(wxDropFilesEvent& event)
void MainFrame::OnAutoImportDir(const wxString& pathToDirectory) void MainFrame::OnAutoImportDir(const wxString& pathToDirectory)
{ {
wxLogDebug(_("Start Importing Samples")); SH_LOG_DEBUG("Start Importing Samples");
wxBusyCursor busy_cursor; wxBusyCursor busy_cursor;
wxWindowDisabler window_disabler; wxWindowDisabler window_disabler;
@ -898,7 +900,7 @@ void MainFrame::OnAutoImportDir(const wxString& pathToDirectory)
AddSamples(filepath_array); AddSamples(filepath_array);
wxLogDebug(_("Done Importing Samples")); SH_LOG_DEBUG("Done Importing Samples");
} }
// Temporary function to check drag and drop result // Temporary function to check drag and drop result
@ -915,7 +917,7 @@ void LogDragResult(wxDragResult result)
default: msg = "Huh?"; break; default: msg = "Huh?"; break;
} }
wxLogDebug(wxString("Drag result: ") + msg); SH_LOG_DEBUG("Drag result: {}", msg);
} }
void MainFrame::OnDragFromDirCtrl(wxTreeEvent& event) void MainFrame::OnDragFromDirCtrl(wxTreeEvent& event)
@ -933,7 +935,8 @@ void MainFrame::OnDragFromLibrary(wxDataViewEvent& event)
{ {
int selected_row = m_Library->ItemToRow(event.GetItem()); int selected_row = m_Library->ItemToRow(event.GetItem());
if (selected_row < 0) return; if (selected_row < 0)
return;
wxString selection = m_Library->GetTextValue(selected_row, 1); wxString selection = m_Library->GetTextValue(selected_row, 1);
@ -944,7 +947,7 @@ void MainFrame::OnDragFromLibrary(wxDataViewEvent& event)
fileData->AddFile(sample_path); fileData->AddFile(sample_path);
event.SetDataObject(fileData); event.SetDataObject(fileData);
wxLogDebug(_("Started dragging '%s'."), sample_path); SH_LOG_DEBUG("Started dragging '{}'.", sample_path);
} }
void MainFrame::OnClickPlay(wxCommandEvent& event) void MainFrame::OnClickPlay(wxCommandEvent& event)
@ -968,15 +971,13 @@ void MainFrame::OnClickPlay(wxCommandEvent& event)
void MainFrame::OnClickLoop(wxCommandEvent& event) void MainFrame::OnClickLoop(wxCommandEvent& event)
{ {
if (m_LoopButton->GetValue()) bLoop = m_LoopButton->GetValue();
bLoop = true;
else
bLoop = false;
} }
void MainFrame::OnClickStop(wxCommandEvent& event) void MainFrame::OnClickStop(wxCommandEvent& event)
{ {
m_MediaCtrl->Stop(); m_MediaCtrl->Stop();
bStopped = true; bStopped = true;
if (m_Timer->IsRunning()) if (m_Timer->IsRunning())
@ -1018,7 +1019,7 @@ void MainFrame::OnMediaFinished(wxMediaEvent& event)
if (m_Timer->IsRunning()) if (m_Timer->IsRunning())
{ {
m_Timer->Stop(); m_Timer->Stop();
wxLogDebug("TIMER STOPPED"); SH_LOG_DEBUG("TIMER STOPPED");
} }
m_SamplePosition->SetLabel("--:--/--:--"); m_SamplePosition->SetLabel("--:--/--:--");
@ -1029,7 +1030,7 @@ void MainFrame::OnMediaFinished(wxMediaEvent& event)
void MainFrame::UpdateElapsedTime(wxTimerEvent& event) void MainFrame::UpdateElapsedTime(wxTimerEvent& event)
{ {
wxLogDebug("TIMER IS RUNNING.."); SH_LOG_DEBUG("TIMER IS RUNNING..");
wxString duration, position; wxString duration, position;
wxLongLong llLength, llTell; wxLongLong llLength, llTell;
@ -1104,7 +1105,6 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event)
if (selected_row != current_row) if (selected_row != current_row)
{ {
m_Library->SetCurrentItem(event.GetItem()); m_Library->SetCurrentItem(event.GetItem());
wxLogDebug("Triggered");
return; return;
} }
@ -1116,7 +1116,7 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event)
if (m_Timer->IsRunning()) if (m_Timer->IsRunning())
{ {
m_Timer->Stop(); m_Timer->Stop();
wxLogDebug("TIMER STOPPED"); SH_LOG_DEBUG("TIMER STOPPED");
} }
wxString selection = m_Library->GetTextValue(selected_row, 1); wxString selection = m_Library->GetTextValue(selected_row, 1);
@ -1151,8 +1151,6 @@ void MainFrame::OnClickLibrary(wxDataViewEvent& event)
} }
else else
{ {
wxLogDebug(_("Adding sample to favorite.."));
wxString msg; wxString msg;
// Get hive name and location // Get hive name and location
@ -1265,17 +1263,16 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
wxString msg; wxString msg;
wxTextEntryDialog* renameEntry; wxTextEntryDialog renameEntry(this, _("Enter new name"), wxGetTextFromUserPromptStr,
renameEntry = new wxTextEntryDialog(this, _("Enter new name"), wxGetTextFromUserPromptStr,
wxEmptyString, wxTextEntryDialogStyle, wxDefaultPosition); wxEmptyString, wxTextEntryDialogStyle, wxDefaultPosition);
renameEntry->SetTextValidator(wxFILTER_EMPTY); renameEntry.SetTextValidator(wxFILTER_EMPTY);
switch (renameEntry->ShowModal()) switch (renameEntry.ShowModal())
{ {
case wxID_OK: case wxID_OK:
{ {
wxString hive_name = renameEntry->GetValue(); wxString hive_name = renameEntry.GetValue();
while(!nodes.empty()) while(!nodes.empty())
{ {
@ -1285,15 +1282,12 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
if (m_Hives->GetItemText(current_item) == hive_name) if (m_Hives->GetItemText(current_item) == hive_name)
{ {
found_item = current_item; found_item = current_item;
wxLogDebug(_("Found item: %s"), m_Hives->GetItemText(current_item)); SH_LOG_DEBUG("Found item: {}", m_Hives->GetItemText(current_item));
break; break;
} }
wxDataViewItem child = m_Hives->GetNthChild(wxDataViewItem(wxNullPtr), 0); wxDataViewItem child = m_Hives->GetNthChild(wxDataViewItem(wxNullPtr), 0);
wxLogDebug("Row: %d :: Hive count: %d :: Child: %s",
row, hive_count, m_Hives->GetItemText(child));
while (row < (hive_count - 1)) while (row < (hive_count - 1))
{ {
row ++; row ++;
@ -1320,8 +1314,6 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
if (sample_count <= 0) if (sample_count <= 0)
{ {
wxLogDebug("Sample count: %d", sample_count);
m_Hives->SetItemText(selected_hive, hive_name); m_Hives->SetItemText(selected_hive, hive_name);
m_Database->UpdateHive(selected_hive_name.ToStdString(), m_Database->UpdateHive(selected_hive_name.ToStdString(),
hive_name.ToStdString()); hive_name.ToStdString());
@ -1336,9 +1328,6 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
m_Hives->GetItemText(sample_item).BeforeLast('.') : m_Hives->GetItemText(sample_item).BeforeLast('.') :
m_Hives->GetItemText(sample_item); m_Hives->GetItemText(sample_item);
wxLogDebug("Sample count: %d :: Sample name: %s",
sample_count, sample_name);
m_Database->UpdateHiveName(sample_name.ToStdString(), m_Database->UpdateHiveName(sample_name.ToStdString(),
hive_name.ToStdString()); hive_name.ToStdString());
m_Database->UpdateHive(selected_hive_name.ToStdString(), m_Database->UpdateHive(selected_hive_name.ToStdString(),
@ -1450,7 +1439,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
if (child_name == matched_sample) if (child_name == matched_sample)
{ {
wxLogDebug(_("Found match")); SH_LOG_DEBUG("Found match");
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)),
i, 0); i, 0);
@ -1462,7 +1451,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
break; break;
} }
else else
wxLogDebug(_("No match found")); SH_LOG_DEBUG("No match found");
} }
} }
@ -1495,7 +1484,8 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
{ {
const auto dataset = m_Database->FilterDatabaseByHiveName(hive_name.ToStdString(), const auto dataset = m_Database->FilterDatabaseByHiveName(hive_name.ToStdString(),
serializer.DeserializeShowFileExtensionSetting(), serializer.DeserializeShowFileExtensionSetting(),
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px); ICON_STAR_FILLED_16px,
ICON_STAR_EMPTY_16px);
if (dataset.empty()) if (dataset.empty())
{ {
@ -1507,8 +1497,6 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
{ {
m_Library->DeleteAllItems(); m_Library->DeleteAllItems();
wxLogDebug("Hive name: %s", hive_name);
for (auto data : dataset) for (auto data : dataset)
{ {
m_Library->AppendItem(data); m_Library->AppendItem(data);
@ -1576,7 +1564,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
if(selected_sample_name == matched_sample) if(selected_sample_name == matched_sample)
{ {
wxLogDebug(_("Found match")); SH_LOG_DEBUG("Found match");
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0); m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
@ -1608,7 +1596,7 @@ void MainFrame::OnShowHivesContextMenu(wxDataViewEvent& event)
if(selected_sample_name == matched_sample) if(selected_sample_name == matched_sample)
{ {
wxLogDebug(_("Found match")); SH_LOG_DEBUG("Found match");
wxDataViewItem matched_item = m_Library->RowToItem(i); wxDataViewItem matched_item = m_Library->RowToItem(i);
@ -1776,19 +1764,17 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
wxDataViewItemArray items; wxDataViewItemArray items;
int rows = m_Library->GetSelections(items); int rows = m_Library->GetSelections(items);
wxMessageDialog singleMsgDialog(this, wxString::Format( wxMessageDialog singleMsgDialog(this, wxString::Format(_("Are you sure you want to delete "
_("Are you sure you want to delete "
"%s from database? " "%s from database? "
"Warning this change is " "Warning this change is "
"permanent, and cannot be " "permanent, and cannot be undone."),
"undone."), sample_path.AfterLast('/')), sample_path.AfterLast('/')),
wxMessageBoxCaptionStr, wxMessageBoxCaptionStr,
wxYES_NO | wxNO_DEFAULT | wxYES_NO | wxNO_DEFAULT |
wxICON_QUESTION | wxSTAY_ON_TOP | wxICON_QUESTION | wxSTAY_ON_TOP |
wxCENTER); wxCENTER);
wxMessageDialog multipleMsgDialog(this, wxString::Format( wxMessageDialog multipleMsgDialog(this, wxString::Format(_("Are you sure you want to delete "
_("Are you sure you want to delete "
"%d selected samples from database? " "%d selected samples from database? "
"Warning this change is " "Warning this change is "
"permanent, and cannot be " "permanent, and cannot be "
@ -1808,8 +1794,6 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
{ {
case wxID_YES: case wxID_YES:
{ {
wxLogDebug("Selected row: %d :: Sample: %s", selected_row, filename);
m_Database->RemoveSampleFromDatabase(filename); m_Database->RemoveSampleFromDatabase(filename);
m_Library->DeleteItem(selected_row); m_Library->DeleteItem(selected_row);
@ -1903,7 +1887,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
wxDataViewItem container, child; wxDataViewItem container, child;
if (m_Database->IsTrashed(filename)) if (m_Database->IsTrashed(filename))
wxLogDebug(_("Already trashed..")); SH_LOG_INFO("{} already trashed", filename);
else else
{ {
wxDataViewItemArray items; wxDataViewItemArray items;
@ -1975,13 +1959,13 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
switch (tagEditor->ShowModal()) switch (tagEditor->ShowModal())
{ {
case wxID_OK: case wxID_OK:
wxLogDebug("tags dialog ok, Return code: %d", tagEditor->GetReturnCode()); SH_LOG_DEBUG("tags dialog ok, Return code: {}", tagEditor->GetReturnCode());
break; break;
case wxID_APPLY: case wxID_APPLY:
wxLogDebug("tags dialog apply, Return code: %d", tagEditor->GetReturnCode()); SH_LOG_DEBUG("tags dialog apply, Return code: {}", tagEditor->GetReturnCode());
break; break;
case wxID_CANCEL: case wxID_CANCEL:
wxLogDebug("tags dialog cancel, Return code: %d", tagEditor->GetReturnCode()); SH_LOG_DEBUG("tags dialog cancel, Return code: {}", tagEditor->GetReturnCode());
break; break;
default: default:
msg = _("Unexpected TagEditor return code!"); msg = _("Unexpected TagEditor return code!");
@ -1996,6 +1980,7 @@ void MainFrame::OnShowLibraryContextMenu(wxDataViewEvent& event)
default: default:
wxMessageBox(_("Unexpected wxMenu return code!"), _("Error!"), wxMessageBox(_("Unexpected wxMenu return code!"), _("Error!"),
wxOK | wxICON_ERROR | wxCENTRE, this); wxOK | wxICON_ERROR | wxCENTRE, this);
break;
} }
if(!msg.IsEmpty()) if(!msg.IsEmpty())
@ -2016,15 +2001,24 @@ void MainFrame::OnShowLibraryColumnHeaderContextMenu(wxDataViewEvent& event)
wxDataViewColumn* BitrateColumn = m_Library->GetColumn(7); wxDataViewColumn* BitrateColumn = m_Library->GetColumn(7);
wxDataViewColumn* PathColumn = m_Library->GetColumn(8); wxDataViewColumn* PathColumn = m_Library->GetColumn(8);
menu.AppendCheckItem(MN_ColumnFavorite, _("Favorites"), _("Toggle favorites column"))->Check(FavoriteColumn->IsShown()); menu.AppendCheckItem(MN_ColumnFavorite, _("Favorites"),
menu.AppendCheckItem(MN_ColumnFilename, _("Filename"), _("Toggle filename column"))->Check(FilenameColumn->IsShown()); _("Toggle favorites column"))->Check(FavoriteColumn->IsShown());
menu.AppendCheckItem(MN_ColumnSamplePack, _("Sample Pack"), _("Toggle sample pack column"))->Check(SamplePackColumn->IsShown()); menu.AppendCheckItem(MN_ColumnFilename, _("Filename"),
menu.AppendCheckItem(MN_ColumnType, _("Type"), _("Toggle type column"))->Check(TypeColumn->IsShown()); _("Toggle filename column"))->Check(FilenameColumn->IsShown());
menu.AppendCheckItem(MN_ColumnChannels, _("Channels"), _("Toggle channels column"))->Check(ChannelsColumn->IsShown()); menu.AppendCheckItem(MN_ColumnSamplePack, _("Sample Pack"),
menu.AppendCheckItem(MN_ColumnLength, _("Length"), _("Toggle length column"))->Check(LengthColumn->IsShown()); _("Toggle sample pack column"))->Check(SamplePackColumn->IsShown());
menu.AppendCheckItem(MN_ColumnSampleRate, _("Sample Rate"), _("Toggle sample rate column"))->Check(SampleRateColumn->IsShown()); menu.AppendCheckItem(MN_ColumnType, _("Type"),
menu.AppendCheckItem(MN_ColumnBitrate, _("Bitrate"), _("Toggle bitrate column"))->Check(BitrateColumn->IsShown()); _("Toggle type column"))->Check(TypeColumn->IsShown());
menu.AppendCheckItem(MN_ColumnPath, _("Path"), _("Toggle path column"))->Check(PathColumn->IsShown()); menu.AppendCheckItem(MN_ColumnChannels, _("Channels"),
_("Toggle channels column"))->Check(ChannelsColumn->IsShown());
menu.AppendCheckItem(MN_ColumnLength, _("Length"),
_("Toggle length column"))->Check(LengthColumn->IsShown());
menu.AppendCheckItem(MN_ColumnSampleRate, _("Sample Rate"),
_("Toggle sample rate column"))->Check(SampleRateColumn->IsShown());
menu.AppendCheckItem(MN_ColumnBitrate, _("Bitrate"),
_("Toggle bitrate column"))->Check(BitrateColumn->IsShown());
menu.AppendCheckItem(MN_ColumnPath, _("Path"),
_("Toggle path column"))->Check(PathColumn->IsShown());
switch (m_Library->GetPopupMenuSelectionFromUser(menu, event.GetPosition())) switch (m_Library->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
{ {
@ -2072,7 +2066,7 @@ void MainFrame::LoadDatabase()
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px); ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
if (dataset.empty()) if (dataset.empty())
wxLogInfo(_("Error! Database is empty.")); SH_LOG_INFO("Error! Database is empty.");
else else
{ {
for (auto data : dataset) for (auto data : dataset)
@ -2104,8 +2098,6 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
{ {
case MN_DeleteTrash: case MN_DeleteTrash:
{ {
wxLogDebug(_("Delete permanently"));
wxString trashed_item_name = serializer.DeserializeShowFileExtensionSetting() ? wxString trashed_item_name = serializer.DeserializeShowFileExtensionSetting() ?
m_Trash->GetItemText(selected_trashed_item).BeforeLast('.') : m_Trash->GetItemText(selected_trashed_item).BeforeLast('.') :
m_Trash->GetItemText(selected_trashed_item); m_Trash->GetItemText(selected_trashed_item);
@ -2113,12 +2105,12 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
m_Database->RemoveSampleFromDatabase(trashed_item_name.ToStdString()); m_Database->RemoveSampleFromDatabase(trashed_item_name.ToStdString());
m_Trash->Delete(selected_trashed_item); m_Trash->Delete(selected_trashed_item);
SH_LOG_INFO("{} deleted from trash and databse", trashed_item_name);
} }
break; break;
case MN_RestoreTrashedItem: case MN_RestoreTrashedItem:
{ {
wxLogDebug(_("Restore sample"));
wxArrayTreeItemIds selected_item_ids; wxArrayTreeItemIds selected_item_ids;
m_Trash->GetSelections(selected_item_ids); m_Trash->GetSelections(selected_item_ids);
@ -2132,9 +2124,6 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
{ {
selected_item_text = m_Trash->GetItemText(selected_item_ids[i]); selected_item_text = m_Trash->GetItemText(selected_item_ids[i]);
wxLogDebug("Count: %d :: Selected item text: %s",
static_cast<int>(selected_item_ids.GetCount()), selected_item_text);
filename = GetFilenamePathAndExtension(selected_item_text).Filename; filename = GetFilenamePathAndExtension(selected_item_text).Filename;
file_data.AddFile(filename); file_data.AddFile(filename);
@ -2148,10 +2137,12 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
wxVector<wxVector<wxVariant>> dataset; wxVector<wxVector<wxVariant>> dataset;
if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(), if (m_Database->RestoreFromTrashByFilename(files[i].ToStdString(),
dataset, serializer.DeserializeShowFileExtensionSetting(), dataset,
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty()) serializer.DeserializeShowFileExtensionSetting(),
ICON_STAR_FILLED_16px,
ICON_STAR_EMPTY_16px).empty())
{ {
wxLogDebug(_("Error! Database is empty.")); SH_LOG_INFO("Error! Database is empty.");
} }
else else
{ {
@ -2167,6 +2158,8 @@ void MainFrame::OnShowTrashContextMenu(wxTreeEvent& event)
} }
m_Trash->Delete(selected_item_ids[i]); m_Trash->Delete(selected_item_ids[i]);
SH_LOG_INFO("{} restored from trash", files[i]);
} }
} }
break; break;
@ -2262,18 +2255,16 @@ void MainFrame::OnClickAddHive(wxCommandEvent& event)
wxString msg; wxString msg;
wxTextEntryDialog* hiveEntry; wxTextEntryDialog hiveEntry(this, _("Enter hive name"), _("Create new hive"), wxEmptyString,
hiveEntry = new wxTextEntryDialog(this, _("Enter hive name"),
_("Create new hive"), wxEmptyString,
wxTextEntryDialogStyle, wxDefaultPosition); wxTextEntryDialogStyle, wxDefaultPosition);
hiveEntry->SetTextValidator(wxFILTER_EMPTY); hiveEntry.SetTextValidator(wxFILTER_EMPTY);
switch (hiveEntry->ShowModal()) switch (hiveEntry.ShowModal())
{ {
case wxID_OK: case wxID_OK:
{ {
wxString hive_name = hiveEntry->GetValue(); wxString hive_name = hiveEntry.GetValue();
while(!nodes.empty()) while(!nodes.empty())
{ {
@ -2283,15 +2274,12 @@ void MainFrame::OnClickAddHive(wxCommandEvent& event)
if (m_Hives->GetItemText(current_item) == hive_name) if (m_Hives->GetItemText(current_item) == hive_name)
{ {
found_item = current_item; found_item = current_item;
wxLogDebug(_("Found item: %s"), m_Hives->GetItemText(current_item)); SH_LOG_DEBUG("Found item: {}", m_Hives->GetItemText(current_item));
break; break;
} }
wxDataViewItem child = m_Hives->GetNthChild(wxDataViewItem(wxNullPtr), 0); wxDataViewItem child = m_Hives->GetNthChild(wxDataViewItem(wxNullPtr), 0);
wxLogDebug("Row: %d :: Hive count: %d :: Child: %s",
row, hive_count, m_Hives->GetItemText(child));
while (row < (hive_count - 1)) while (row < (hive_count - 1))
{ {
row ++; row ++;
@ -2305,8 +2293,8 @@ void MainFrame::OnClickAddHive(wxCommandEvent& event)
if (found_item.IsOk()) if (found_item.IsOk())
{ {
wxMessageBox(wxString::Format( wxMessageBox(wxString::Format(_("Another hive by the name %s already exist. "
_("Another hive by the name %s already exist. Please try with a different name."), "Please try with a different name."),
hive_name), hive_name),
_("Error!"), wxOK | wxCENTRE, this); _("Error!"), wxOK | wxCENTRE, this);
} }
@ -2338,16 +2326,14 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
wxString msg; wxString msg;
wxMessageDialog deleteEmptyHiveDialog(this, wxString::Format( wxMessageDialog deleteEmptyHiveDialog(this, wxString::Format(_("Are you sure you want to delete "
_("Are you sure you want to delete "
"%s from hives?"), "%s from hives?"),
hive_name), hive_name),
wxMessageBoxCaptionStr, wxMessageBoxCaptionStr,
wxYES_NO | wxNO_DEFAULT | wxYES_NO | wxNO_DEFAULT |
wxICON_QUESTION | wxSTAY_ON_TOP); wxICON_QUESTION | wxSTAY_ON_TOP);
wxMessageDialog deleteFilledHiveDialog(this, wxString::Format( wxMessageDialog deleteFilledHiveDialog(this, wxString::Format(_("Are you sure you want to delete "
_("Are you sure you want to delete "
"%s and all sample inside %s from hives?"), "%s and all sample inside %s from hives?"),
hive_name, hive_name), hive_name, hive_name),
wxMessageBoxCaptionStr, wxMessageBoxCaptionStr,
@ -2418,7 +2404,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
if (child_name == matched_sample) if (child_name == matched_sample)
{ {
wxLogDebug(_("Found match")); SH_LOG_DEBUG("Found match");
m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0); m_Library->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
@ -2429,7 +2415,7 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
break; break;
} }
else else
wxLogDebug(_("No match found")); SH_LOG_DEBUG("No match found");
} }
} }
@ -2438,7 +2424,8 @@ void MainFrame::OnClickRemoveHive(wxCommandEvent& event)
m_Database->RemoveHiveFromDatabase(hive_name.ToStdString()); m_Database->RemoveHiveFromDatabase(hive_name.ToStdString());
msg = wxString::Format(_("%s and all samples inside %s have been deleted from hives successfully."), msg = wxString::Format(_("%s and all samples inside %s have been deleted "
"from hives successfully."),
hive_name, hive_name); hive_name, hive_name);
} }
break; break;
@ -2483,9 +2470,6 @@ void MainFrame::OnClickRestoreTrashItem(wxCommandEvent& event)
{ {
selected_item_text = m_Trash->GetItemText(selected_item_ids[i]); selected_item_text = m_Trash->GetItemText(selected_item_ids[i]);
wxLogDebug("Count: %d :: Selected item text: %s",
static_cast<int>(selected_item_ids.GetCount()), selected_item_text);
filename = GetFilenamePathAndExtension(selected_item_text).Filename; filename = GetFilenamePathAndExtension(selected_item_text).Filename;
file_data.AddFile(filename); file_data.AddFile(filename);
@ -2502,7 +2486,7 @@ void MainFrame::OnClickRestoreTrashItem(wxCommandEvent& event)
serializer.DeserializeShowFileExtensionSetting(), serializer.DeserializeShowFileExtensionSetting(),
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty()) ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty())
{ {
wxLogDebug(_("Error! Database is empty.")); SH_LOG_INFO("Error! Database is empty.");
} }
else else
{ {
@ -2529,12 +2513,14 @@ void MainFrame::OnDoSearch(wxCommandEvent& event)
try try
{ {
const auto dataset = m_Database->FilterDatabaseBySampleName(search, serializer.DeserializeShowFileExtensionSetting(), const auto dataset = m_Database->FilterDatabaseBySampleName(search,
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px); serializer.DeserializeShowFileExtensionSetting(),
ICON_STAR_FILLED_16px,
ICON_STAR_EMPTY_16px);
if (dataset.empty()) if (dataset.empty())
{ {
wxLogDebug(_("Error! Database is empty.")); SH_LOG_INFO("Error! Database is empty.");
} }
else else
{ {
@ -2568,8 +2554,7 @@ void MainFrame::LoadConfigFile()
wxPOSIX_GROUP_READ | wxPOSIX_GROUP_EXECUTE | wxPOSIX_GROUP_READ | wxPOSIX_GROUP_EXECUTE |
wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_EXECUTE, wxPATH_MKDIR_FULL)) wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_EXECUTE, wxPATH_MKDIR_FULL))
{ {
wxLogDebug(wxString::Format(_("Successfully created configuratin directory at %s"), SH_LOG_INFO("Successfully created configuratin directory at {}", APP_CONFIG_DIR);
APP_CONFIG_DIR));
} }
else else
{ {
@ -2585,7 +2570,7 @@ void MainFrame::LoadConfigFile()
wxPOSIX_GROUP_READ | wxPOSIX_GROUP_EXECUTE | wxPOSIX_GROUP_READ | wxPOSIX_GROUP_EXECUTE |
wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_EXECUTE, wxPATH_MKDIR_FULL)) wxPOSIX_OTHERS_READ | wxPOSIX_OTHERS_EXECUTE, wxPATH_MKDIR_FULL))
{ {
wxLogDebug(wxString::Format(_("Successfully created data directory at %s"), APP_DATA_DIR)); SH_LOG_INFO("Successfully created data directory at {}", APP_DATA_DIR);
} }
else else
{ {
@ -2596,7 +2581,7 @@ void MainFrame::LoadConfigFile()
Serializer serialize(m_ConfigFilepath); Serializer serialize(m_ConfigFilepath);
wxLogDebug(_("Reading from configuration file..")); SH_LOG_INFO("Reading configuration file..");
int height = 600, width = 800; int height = 600, width = 800;
@ -2631,8 +2616,6 @@ void MainFrame::RefreshDatabase()
{ {
m_Library->DeleteAllItems(); m_Library->DeleteAllItems();
wxLogDebug("Count: %d", m_Hives->GetChildCount(wxDataViewItem(wxNullPtr)));
if (m_Hives->GetChildCount(wxDataViewItem(wxNullPtr)) < 1 && if (m_Hives->GetChildCount(wxDataViewItem(wxNullPtr)) < 1 &&
m_Hives->GetItemText(wxDataViewItem(wxNullPtr)) == m_Hives->GetItemText(favorites_hive)) m_Hives->GetItemText(wxDataViewItem(wxNullPtr)) == m_Hives->GetItemText(favorites_hive))
return; return;
@ -2659,7 +2642,7 @@ void MainFrame::CreateWatcher()
{ {
Serializer serializer(m_ConfigFilepath); Serializer serializer(m_ConfigFilepath);
wxCHECK_RET(!m_FsWatcher, "Watcher already initialized"); wxCHECK_RET(!m_FsWatcher, _("Watcher already initialized"));
m_FsWatcher = new wxFileSystemWatcher(); m_FsWatcher = new wxFileSystemWatcher();
m_FsWatcher->SetOwner(this); m_FsWatcher->SetOwner(this);
@ -2668,7 +2651,7 @@ void MainFrame::CreateWatcher()
if (serializer.DeserializeAutoImportSettings().first) if (serializer.DeserializeAutoImportSettings().first)
{ {
wxLogDebug("Adding watch entry.."); SH_LOG_INFO("Adding watch entry: {}", path);
AddWatchEntry(wxFSWPath_Tree, path.ToStdString()); AddWatchEntry(wxFSWPath_Tree, path.ToStdString());
} }
} }
@ -2679,21 +2662,18 @@ void MainFrame::AddWatchEntry(wxFSWPathType type, std::string path)
if (path.empty()) if (path.empty())
{ {
path = wxDirSelector("Choose a directory to watch", "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST); path = wxDirSelector(_("Choose a directory to watch"), "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
if (path.empty()) if (path.empty())
return; return;
} }
wxCHECK_RET(m_FsWatcher, "Watcher not initialized"); wxCHECK_RET(m_FsWatcher, _("Watcher not initialized"));
wxLogDebug("Adding %s: '%s'", path, type == wxFSWPath_Dir ? "directory" : "directory tree"); SH_LOG_INFO("Adding {}: '{}'", path, type == wxFSWPath_Dir ? "directory" : "directory tree");
wxFileName filename = wxFileName::DirName(path); wxFileName filename = wxFileName::DirName(path);
if (filename.IsDir() && filename.IsDirReadable() && filename.IsOk())
wxLogDebug("Path is ok, adding to watch list.");
if (!serializer.DeserializeFollowSymLink()) if (!serializer.DeserializeFollowSymLink())
{ {
filename.DontFollowLink(); filename.DontFollowLink();
@ -2711,12 +2691,12 @@ void MainFrame::AddWatchEntry(wxFSWPathType type, std::string path)
case wxFSWPath_File: case wxFSWPath_File:
break; break;
case wxFSWPath_None: case wxFSWPath_None:
wxFAIL_MSG("Unexpected path type."); wxFAIL_MSG(_("Error! Unexpected path type."));
} }
if (!ok) if (!ok)
{ {
wxLogError("Error! Cannot add '%s' to watched paths", filename.GetPath()); SH_LOG_ERROR("Error! Cannot add '{}' to watched paths", filename.GetPath());
return; return;
} }
} }
@ -2732,31 +2712,31 @@ void MainFrame::OnFileSystemEvent(wxFileSystemWatcherEvent& event)
wxArrayString files; wxArrayString files;
files.push_back(path); files.push_back(path);
wxLogDebug("%s %s", path, event.ToString()); SH_LOG_DEBUG("{} {}", path, event.ToString());
switch (type) switch (type)
{ {
case wxFSW_EVENT_CREATE: case wxFSW_EVENT_CREATE:
wxLogDebug("NEW FILES DETECTED, ADDING: %s", path); SH_LOG_INFO("NEW FILES DETECTED, ADDING: {}", path);
AddSamples(files); AddSamples(files);
break; break;
case wxFSW_EVENT_ACCESS: case wxFSW_EVENT_ACCESS:
wxLogDebug("ACCESSING DIRECTORY: %s", path); SH_LOG_INFO("ACCESSING DIRECTORY: {}", path);
break; break;
case wxFSW_EVENT_DELETE: case wxFSW_EVENT_DELETE:
wxLogDebug("FILES DELETED IN DIRECTORY: %s", path); SH_LOG_INFO("FILES DELETED IN DIRECTORY: {}", path);
break; break;
case wxFSW_EVENT_MODIFY: case wxFSW_EVENT_MODIFY:
wxLogDebug("DIRECTORY MODIFIED: %s", path); SH_LOG_INFO("DIRECTORY MODIFIED: {}", path);
break; break;
case wxFSW_EVENT_RENAME: case wxFSW_EVENT_RENAME:
wxLogDebug("FILES RENAMED IN DIRECTORY: %s", event.GetNewPath().GetFullPath()); SH_LOG_INFO("FILES RENAMED IN DIRECTORY: {}", event.GetNewPath().GetFullPath());
break; break;
case wxFSW_EVENT_WARNING: case wxFSW_EVENT_WARNING:
wxLogDebug("Filesystem watcher warning: %d", event.GetWarningType()); SH_LOG_INFO("Filesystem watcher warning: {}", event.GetWarningType());
break; break;
case wxFSW_EVENT_ERROR: case wxFSW_EVENT_ERROR:
wxLogDebug("Error! Filesystem watcher: %s", event.GetErrorDescription()); SH_LOG_INFO("Error! Filesystem watcher: {}", event.GetErrorDescription());
break; break;
default: default:
break; break;
@ -2792,13 +2772,13 @@ FileInfo MainFrame::GetFilenamePathAndExtension(const wxString& selected,
void MainFrame::OnHiveStartEditing(wxDataViewEvent &event) void MainFrame::OnHiveStartEditing(wxDataViewEvent &event)
{ {
wxLogDebug(_("Right click on a hive and select rename to rename it..")); SH_LOG_INFO("Right click on a hive and select rename to rename it..");
event.Veto(); event.Veto();
} }
void MainFrame::OnSelectAddFile(wxCommandEvent& event) void MainFrame::OnSelectAddFile(wxCommandEvent& event)
{ {
wxFileDialog file_dialog(this, wxFileSelectorPromptStr, wxGetHomeDir(), wxFileDialog file_dialog(this, wxFileSelectorPromptStr, USER_HOME_DIR,
wxEmptyString, wxFileSelectorDefaultWildcardStr, wxEmptyString, wxFileSelectorDefaultWildcardStr,
wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_PREVIEW, wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE | wxFD_PREVIEW,
wxDefaultPosition, wxDefaultSize); wxDefaultPosition, wxDefaultSize);
@ -2821,7 +2801,7 @@ void MainFrame::OnSelectAddFile(wxCommandEvent& event)
void MainFrame::OnSelectAddDirectory(wxCommandEvent& event) void MainFrame::OnSelectAddDirectory(wxCommandEvent& event)
{ {
wxDirDialog dir_dialog(this, wxDirSelectorPromptStr, wxGetHomeDir(), wxDirDialog dir_dialog(this, wxDirSelectorPromptStr, USER_HOME_DIR,
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST, wxDefaultPosition, wxDefaultSize); wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST, wxDefaultPosition, wxDefaultSize);
switch (dir_dialog.ShowModal()) switch (dir_dialog.ShowModal())
@ -2939,7 +2919,7 @@ void MainFrame::OnSelectResetAppData(wxCommandEvent& event)
"\"%s\" and database file \"%s\" permanently, " "\"%s\" and database file \"%s\" permanently, "
"are you sure you want to delete these files?"), "are you sure you want to delete these files?"),
m_ConfigFilepath, m_DatabaseFilepath), m_ConfigFilepath, m_DatabaseFilepath),
_("Clear app data"), _("Clear app data?"),
wxYES_NO | wxNO_DEFAULT | wxCENTRE, wxDefaultPosition); wxYES_NO | wxNO_DEFAULT | wxCENTRE, wxDefaultPosition);
bool remove = false; bool remove = false;
@ -2951,21 +2931,21 @@ void MainFrame::OnSelectResetAppData(wxCommandEvent& event)
if (remove) if (remove)
{ {
bool configIsDeleted = wxRemoveFile(m_ConfigFilepath); bool config_is_deleted = wxRemoveFile(m_ConfigFilepath);
if (configIsDeleted) if (config_is_deleted)
wxLogDebug("Deleted %s", m_ConfigFilepath); SH_LOG_INFO("Deleted {}", m_ConfigFilepath);
else else
wxLogDebug("Could not delete %s", m_ConfigFilepath); SH_LOG_ERROR("Could not delete {}", m_ConfigFilepath);
bool dbIsDeleted = wxRemoveFile(m_DatabaseFilepath); bool db_is_deleted = wxRemoveFile(m_DatabaseFilepath);
if (dbIsDeleted) if (db_is_deleted)
wxLogDebug("Deleted %s", m_DatabaseFilepath); SH_LOG_INFO("Deleted {}", m_DatabaseFilepath);
else else
wxLogDebug("Could not delete %s", m_DatabaseFilepath); SH_LOG_ERROR("Could not delete {}", m_DatabaseFilepath);
if (configIsDeleted && dbIsDeleted) if (config_is_deleted && db_is_deleted)
m_InfoBar->ShowMessage(_("Successfully cleared app data"), wxICON_INFORMATION); m_InfoBar->ShowMessage(_("Successfully cleared app data"), wxICON_INFORMATION);
else else
wxMessageBox(_("Error! Could not clear app data"), _("Error!"), wxMessageBox(_("Error! Could not clear app data"), _("Error!"),
@ -3033,8 +3013,6 @@ void MainFrame::SetAfterFrameCreate()
void MainFrame::OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event) void MainFrame::OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event)
{ {
wxLogDebug("%s called and recieved loop points", __FUNCTION__);
std::pair<double, double> loop_points = event.GetLoopPoints(); std::pair<double, double> loop_points = event.GetLoopPoints();
m_LoopA = wxLongLong(loop_points.first); m_LoopA = wxLongLong(loop_points.first);
@ -3045,14 +3023,12 @@ void MainFrame::OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event)
int loopB_min = static_cast<int>((m_LoopB / 60000).GetValue()); int loopB_min = static_cast<int>((m_LoopB / 60000).GetValue());
int loopB_sec = static_cast<int>(((m_LoopB % 60000) / 1000).GetValue()); int loopB_sec = static_cast<int>(((m_LoopB % 60000) / 1000).GetValue());
wxLogDebug(wxString::Format("LoopA: %2i:%02i, LoopB: %2i:%02i", // SH_LOG_INFO(wxString::Format(_("Loop points set: A: %2i:%02i, B: %2i:%02i"),
loopA_min, loopA_sec, loopB_min, loopB_sec)); // loopA_min, loopA_sec, loopB_min, loopB_sec));
m_LoopABButton->SetValue(true); m_LoopABButton->SetValue(true);
bLoopPointsSet = true; bLoopPointsSet = true;
wxLogDebug("%s Event processed successfully..", __FUNCTION__);
} }
void MainFrame::OnRecieveStatusBarStatus(SampleHive::SH_StatusBarMessageEvent& event) void MainFrame::OnRecieveStatusBarStatus(SampleHive::SH_StatusBarMessageEvent& event)
@ -3073,15 +3049,13 @@ void MainFrame::ClearLoopPoints()
void MainFrame::PlaySample(const std::string& filepath, const std::string& sample, void MainFrame::PlaySample(const std::string& filepath, const std::string& sample,
bool seek, wxFileOffset where, wxSeekMode mode) bool seek, wxFileOffset where, wxSeekMode mode)
{ {
wxLogDebug("TIMER STARTING FROM %s", __FUNCTION__);
if (m_MediaCtrl->Load(filepath)) if (m_MediaCtrl->Load(filepath))
{ {
if (seek) if (seek)
m_MediaCtrl->Seek(where, mode); m_MediaCtrl->Seek(where, mode);
if (!m_MediaCtrl->Play()) if (!m_MediaCtrl->Play())
wxLogDebug(_("Error! Cannot play sample.")); SH_LOG_ERROR("Error! Cannot play sample.");
PushStatusText(wxString::Format(_("Now playing: %s"), sample), 1); PushStatusText(wxString::Format(_("Now playing: %s"), sample), 1);
@ -3089,7 +3063,7 @@ void MainFrame::PlaySample(const std::string& filepath, const std::string& sampl
m_Timer->Start(20, wxTIMER_CONTINUOUS); m_Timer->Start(20, wxTIMER_CONTINUOUS);
} }
else else
wxLogDebug(_("Error! Cannot load sample.")); SH_LOG_ERROR("Error! Cannot load sample.");
} }
MainFrame::~MainFrame() MainFrame::~MainFrame()

View File

@ -22,6 +22,7 @@
#include "Utility/Serialize.hpp" #include "Utility/Serialize.hpp"
#include "Utility/Tags.hpp" #include "Utility/Tags.hpp"
#include "Utility/SH_Event.hpp" #include "Utility/SH_Event.hpp"
#include "Utility/Log.hpp"
#include <vector> #include <vector>
@ -31,7 +32,6 @@
#include <wx/dcmemory.h> #include <wx/dcmemory.h>
#include <wx/filefn.h> #include <wx/filefn.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/log.h>
#include <wx/pen.h> #include <wx/pen.h>
#include <sndfile.hh> #include <sndfile.hh>
@ -70,7 +70,7 @@ void WaveformViewer::OnPaint(wxPaintEvent& event)
|| m_WaveformBitmap.GetHeight() != size.y || m_WaveformBitmap.GetHeight() != size.y
|| bBitmapDirty) || bBitmapDirty)
{ {
wxLogDebug("Updating waveform bitmap.."); SH_LOG_INFO("Updating waveform bitmap..");
m_WaveformBitmap = wxBitmap(wxImage(size.x, size.y), 32); m_WaveformBitmap = wxBitmap(wxImage(size.x, size.y), 32);
@ -121,15 +121,15 @@ void WaveformViewer::RenderPlayhead(wxDC& dc)
Tags tags(path); Tags tags(path);
int length = tags.GetAudioInfo().length; int length = tags.GetAudioInfo().length;
wxLogDebug("Sample length: %d", length); SH_LOG_DEBUG("Sample length: {}", length);
double position = m_MediaCtrl.Tell(); double position = m_MediaCtrl.Tell();
wxLogDebug("Current Sample Position: %f", position); SH_LOG_DEBUG("Current Sample Position: {}", position);
int panel_width = this->GetSize().GetWidth(); int panel_width = this->GetSize().GetWidth();
double line_pos = panel_width * (position / length); double line_pos = panel_width * (position / length);
wxLogDebug("Drawing playhead at: %f", line_pos); SH_LOG_DEBUG("Drawing playhead at: {}", line_pos);
m_PlayheadColour = wxColor(255, 0, 0, 255); m_PlayheadColour = wxColor(255, 0, 0, 255);
@ -185,7 +185,7 @@ void WaveformViewer::UpdateWaveformBitmap()
float display_width = this->GetSize().GetWidth(); float display_width = this->GetSize().GetWidth();
float display_height = this->GetSize().GetHeight(); float display_height = this->GetSize().GetHeight();
wxLogDebug("Calculating Waveform bars RMS.."); SH_LOG_INFO("Calculating Waveform bars RMS..");
float chunk_size = (float)(frames) / (float)display_width; float chunk_size = (float)(frames) / (float)display_width;
int number_of_chunks = static_cast<int>(static_cast<float>(frames) / chunk_size); int number_of_chunks = static_cast<int>(static_cast<float>(frames) / chunk_size);
@ -235,7 +235,7 @@ void WaveformViewer::UpdateWaveformBitmap()
mdc.SetPen(wxPen(wxColour(m_WaveformColour), 2, wxPENSTYLE_SOLID)); mdc.SetPen(wxPen(wxColour(m_WaveformColour), 2, wxPENSTYLE_SOLID));
wxLogDebug("Drawing bitmap.."); SH_LOG_DEBUG("Drawing bitmap..");
for (int i = 0; i < waveform.size() - 1; i++) for (int i = 0; i < waveform.size() - 1; i++)
{ {
@ -249,7 +249,7 @@ void WaveformViewer::UpdateWaveformBitmap()
mdc.DrawLine(X, half_display_height + Y, X, half_display_height - Y); mdc.DrawLine(X, half_display_height + Y, X, half_display_height - Y);
} }
wxLogDebug("Done drawing bitmap.."); SH_LOG_DEBUG("Done drawing bitmap..");
} }
void WaveformViewer::OnControlKeyDown(wxKeyEvent &event) void WaveformViewer::OnControlKeyDown(wxKeyEvent &event)
@ -314,7 +314,7 @@ void WaveformViewer::OnMouseMotion(wxMouseEvent& event)
if (abs(pos.x - line_pos) <= 5 && pos.y <= 5) if (abs(pos.x - line_pos) <= 5 && pos.y <= 5)
{ {
SetCursor(wxCursor(wxCURSOR_HAND)); SetCursor(wxCursor(wxCURSOR_HAND));
wxLogDebug("Cursor on playhead.."); SH_LOG_DEBUG("Cursor on playhead..");
} }
else if (bSelectRange) else if (bSelectRange)
{ {
@ -322,7 +322,7 @@ void WaveformViewer::OnMouseMotion(wxMouseEvent& event)
Refresh(); Refresh();
wxLogDebug("CTRL pressed, pressing LMB will draw selection range at %d, %d", pos.x, pos.y); SH_LOG_INFO("CTRL pressed, pressing LMB will draw selection range at {}, {}", pos.x, pos.y);
} }
else else
return; return;
@ -354,11 +354,11 @@ void WaveformViewer::OnMouseLeftButtonDown(wxMouseEvent& event)
SetCursor(wxCURSOR_CLOSED_HAND); SetCursor(wxCURSOR_CLOSED_HAND);
CaptureMouse(); CaptureMouse();
wxLogDebug("Mouse Captured playhead.."); SH_LOG_DEBUG("Mouse Captured playhead..");
} }
else if (event.ControlDown()) else if (event.ControlDown())
{ {
wxLogDebug("LMB pressed"); SH_LOG_DEBUG("LMB pressed");
SetCursor(wxCURSOR_CLOSED_HAND); SetCursor(wxCURSOR_CLOSED_HAND);
CaptureMouse(); CaptureMouse();
@ -402,13 +402,13 @@ void WaveformViewer::OnMouseLeftButtonUp(wxMouseEvent& event)
if (!wxWindow::HasCapture()) if (!wxWindow::HasCapture())
{ {
wxLogDebug("Window doesn't have capture skipping.."); SH_LOG_INFO("Window doesn't have capture skipping..");
return; return;
} }
if (bSelectRange) if (bSelectRange)
{ {
wxLogDebug("LMB released"); SH_LOG_DEBUG("LMB released");
m_CurrentPoint = wxPoint(pos.x, pos.y); m_CurrentPoint = wxPoint(pos.x, pos.y);
@ -444,7 +444,7 @@ void WaveformViewer::ResetDC()
void WaveformViewer::SendLoopPoints() void WaveformViewer::SendLoopPoints()
{ {
wxLogDebug("%s Called", __FUNCTION__); SH_LOG_DEBUG("{} Called", __FUNCTION__);
SampleHive::SH_LoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_UPDATED, this->GetId()); SampleHive::SH_LoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_UPDATED, this->GetId());
event.SetEventObject(this); event.SetEventObject(this);
@ -472,7 +472,7 @@ void WaveformViewer::SendLoopPoints()
HandleWindowEvent(event); HandleWindowEvent(event);
wxLogDebug("%s processed event, sending loop points..", __FUNCTION__); SH_LOG_DEBUG("{} processed event, sending loop points..", __FUNCTION__);
} }
void WaveformViewer::SendStatusBarStatus(const wxString& msg, int section) void WaveformViewer::SendStatusBarStatus(const wxString& msg, int section)

26
src/Utility/Log.cpp Normal file
View File

@ -0,0 +1,26 @@
#include "Log.hpp"
#include <iostream>
#include "spdlog/sinks/stdout_color_sinks.h"
namespace SampleHive {
std::shared_ptr<spdlog::logger> Log::s_Logger;
void Log::InitLogger(const std::string& logger)
{
spdlog::set_pattern("%^[%-T] [%-n] [%l]: %v %@%$");
try
{
s_Logger = spdlog::stdout_color_mt(logger);
s_Logger->set_level(spdlog::level::trace);
}
catch (const spdlog::spdlog_ex& ex)
{
std::cout << "Logger initialization failed: " << ex.what() << std::endl;
}
}
}

31
src/Utility/Log.hpp Normal file
View File

@ -0,0 +1,31 @@
#pragma once
#include <memory>
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
#include <spdlog/spdlog.h>
namespace SampleHive {
class Log
{
public:
static void InitLogger(const std::string& logger);
public:
inline static std::shared_ptr<spdlog::logger>& GetLogger() { return s_Logger; }
private:
static std::shared_ptr<spdlog::logger> s_Logger;
};
}
// Log macros
#define SH_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_INFO(...) SPDLOG_LOGGER_INFO(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_WARN(...) SPDLOG_LOGGER_WARN(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(::SampleHive::Log::GetLogger(), __VA_ARGS__)
#define SH_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(::SampleHive::Log::GetLogger(), __VA_ARGS__)

View File

@ -19,12 +19,12 @@
*/ */
#include "Utility/Serialize.hpp" #include "Utility/Serialize.hpp"
#include "Utility/Log.hpp"
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/log.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <yaml-cpp/emittermanip.h> #include <yaml-cpp/emittermanip.h>
@ -43,9 +43,12 @@ Serializer::Serializer(const std::string& filepath)
std::string dir = wxGetHomeDir().ToStdString(); std::string dir = wxGetHomeDir().ToStdString();
// Initialize the logger
// SampleHive::Log::InitLogger("Serializer");
if (!ifstrm) if (!ifstrm)
{ {
wxLogDebug("Genrating configuration file.."); SH_LOG_INFO("Genrating configuration file..");
m_Emitter << YAML::Comment("This is the configuration file for SampleHive," m_Emitter << YAML::Comment("This is the configuration file for SampleHive,"
"feel free to edit the file as needed"); "feel free to edit the file as needed");
@ -94,7 +97,7 @@ Serializer::Serializer(const std::string& filepath)
std::ofstream ofstrm(m_Filepath); std::ofstream ofstrm(m_Filepath);
ofstrm << m_Emitter.c_str(); ofstrm << m_Emitter.c_str();
wxLogDebug("Generated %s successfully!", m_Filepath); SH_LOG_INFO("Generated {} successfully!", m_Filepath);
} }
} }
@ -124,10 +127,10 @@ WindowSize Serializer::DeserializeWinSize() const
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
wxLogDebug("Window size: %d, %d", width, height); SH_LOG_INFO("Window size: {}, {}", width, height);
return { width, height }; return { width, height };
} }
@ -154,11 +157,11 @@ void Serializer::SerializeShowMenuAndStatusBar(std::string key, bool value)
ofstrm << out.c_str(); ofstrm << out.c_str();
} }
else else
wxLogDebug("Error! Cannot store show bar values."); SH_LOG_ERROR("Error! Cannot store show bar values.");
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
} }
@ -180,12 +183,12 @@ bool Serializer::DeserializeShowMenuAndStatusBar(std::string key) const
} }
else else
{ {
wxLogDebug("Error! Cannot fetch show bar values."); SH_LOG_ERROR("Error! Cannot fetch show bar values.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
return show; return show;
@ -216,11 +219,11 @@ void Serializer::SerializeBrowserControls(std::string key, bool value)
ofstrm << out.c_str(); ofstrm << out.c_str();
} }
else else
wxLogDebug("Error! Cannot store media values."); SH_LOG_ERROR("Error! Cannot store media values.");
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
} }
@ -244,14 +247,14 @@ bool Serializer::DeserializeBrowserControls(std::string key) const
control = media["Muted"].as<bool>(); control = media["Muted"].as<bool>();
} }
else else
wxLogDebug("Error! Cannot fetch values."); SH_LOG_ERROR("Error! Cannot fetch values.");
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
wxLogDebug("%s: %s", key, control ? "enabled" : "disabled"); SH_LOG_INFO("{}: {}", key, control ? "enabled" : "disabled");
return control; return control;
} }
@ -281,12 +284,12 @@ void Serializer::SerializeDisplaySettings(wxFont& font)
} }
else else
{ {
wxLogDebug("Error! Cannot store font values."); SH_LOG_ERROR("Error! Cannot store font values.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
} }
@ -313,12 +316,12 @@ wxFont Serializer::DeserializeDisplaySettings() const
} }
else else
{ {
wxLogDebug("Error! Cannot fetch font values."); SH_LOG_ERROR("Error! Cannot fetch font values.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
return font; return font;
@ -347,12 +350,12 @@ void Serializer::SerializeWaveformColour(wxColour& colour)
} }
else else
{ {
wxLogDebug("Error! Cannot store waveform colour."); SH_LOG_ERROR("Error! Cannot store waveform colour.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
} }
@ -372,12 +375,12 @@ wxColour Serializer::DeserializeWaveformColour() const
} }
else else
{ {
wxLogDebug("Error! Cannot fetch waveform colour."); SH_LOG_ERROR("Error! Cannot fetch waveform colour.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
return static_cast<wxString>(colour); return static_cast<wxString>(colour);
@ -403,12 +406,12 @@ void Serializer::SerializeAutoImportSettings(bool autoImport, const std::string&
} }
else else
{ {
wxLogDebug("Error! Cannot store import dir values."); SH_LOG_ERROR("Error! Cannot store import dir values.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
} }
@ -428,12 +431,12 @@ ImportDirInfo Serializer::DeserializeAutoImportSettings() const
} }
else else
{ {
wxLogDebug("Error! Cannot fetch import dir values."); SH_LOG_ERROR("Error! Cannot fetch import dir values.");
} }
} }
catch (const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
return { auto_import, dir }; return { auto_import, dir };
@ -458,12 +461,12 @@ void Serializer::SerializeFollowSymLink(bool followSymLinks)
} }
else else
{ {
wxLogDebug("Error! Cannot store follow symbolic links value."); SH_LOG_ERROR("Error! Cannot store follow symbolic links value.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
} }
@ -481,12 +484,12 @@ bool Serializer::DeserializeFollowSymLink() const
} }
else else
{ {
wxLogDebug("Error! Cannot fetch follow symbolic links value."); SH_LOG_ERROR("Error! Cannot fetch follow symbolic links value.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
return follow_sym_links; return follow_sym_links;
@ -511,14 +514,13 @@ void Serializer::SerializeShowFileExtensionSetting(bool showExtension)
} }
else else
{ {
wxLogDebug("Error! Cannot store show file extension value."); SH_LOG_ERROR("Error! Cannot store show file extension value.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
} }
bool Serializer::DeserializeShowFileExtensionSetting() const bool Serializer::DeserializeShowFileExtensionSetting() const
@ -535,12 +537,12 @@ bool Serializer::DeserializeShowFileExtensionSetting() const
} }
else else
{ {
wxLogDebug("Error! Cannot fetch show file extension value."); SH_LOG_ERROR("Error! Cannot fetch show file extension value.");
} }
} }
catch(const YAML::ParserException& ex) catch(const YAML::ParserException& ex)
{ {
std::cout << ex.what() << std::endl; SH_LOG_ERROR(ex.what());
} }
return show_extension; return show_extension;

12
subprojects/spdlog.wrap Normal file
View File

@ -0,0 +1,12 @@
[wrap-file]
directory = spdlog-1.8.5
source_url = https://github.com/gabime/spdlog/archive/v1.8.5.tar.gz
source_filename = v1.8.5.tar.gz
source_hash = 944d0bd7c763ac721398dca2bb0f3b5ed16f67cef36810ede5061f35a543b4b8
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.8.5-1/get_patch
patch_filename = spdlog-1.8.5-1-wrap.zip
patch_hash = 3c38f275d5792b1286391102594329e98b17737924b344f98312ab09929b74be
[provide]
spdlog = spdlog_dep