Add the ability to set a log filename (non abi breaking change)

This commit is contained in:
Paul Fd 2020-03-26 23:15:50 +01:00
parent 36cb6db974
commit a6cbb48222
8 changed files with 58 additions and 10 deletions

View file

@ -379,6 +379,14 @@ SFIZZ_EXPORTED_API void sfizz_enable_logging(sfizz_synth_t* synth);
*/ */
SFIZZ_EXPORTED_API void sfizz_disable_logging(sfizz_synth_t* synth); SFIZZ_EXPORTED_API void sfizz_disable_logging(sfizz_synth_t* synth);
/**
* @brief Enable logging of timings to sidecar CSV files. This can produce
* many outputs so use with caution.
*
* @param synth
*/
SFIZZ_EXPORTED_API void sfizz_set_logging_prefix(sfizz_synth_t* synth, const char* prefix);
/** /**
* @brief Shuts down the current processing, clear buffers and reset the voices. * @brief Shuts down the current processing, clear buffers and reset the voices.
* *

View file

@ -258,8 +258,22 @@ public:
* @brief Enable logging of timings to sidecar CSV files. This can produce * @brief Enable logging of timings to sidecar CSV files. This can produce
* many outputs so use with caution. * many outputs so use with caution.
* *
* @param prefix the file prefix to use for logging
*/ */
void enableLogging() noexcept; void enableLogging() noexcept;
/**
* @brief Enable logging of timings to sidecar CSV files. This can produce
* many outputs so use with caution.
*
* @param prefix the file prefix to use for logging
*/
void enableLogging(const std::string& prefix) noexcept;
/**
* @brief Set the logging prefix
*
* @param prefix
*/
void setLoggingPrefix(const std::string& prefix) noexcept;
/** /**
* @brief Disable logging; * @brief Disable logging;
* *

View file

@ -112,15 +112,14 @@ void sfz::Logger::logFileTime(std::chrono::duration<double> waitDuration, std::c
fileTimeQueue.try_push<FileTime>({ waitDuration, loadDuration, fileSize, filename }); fileTimeQueue.try_push<FileTime>({ waitDuration, loadDuration, fileSize, filename });
} }
void sfz::Logger::setPrefix(const std::string& prefix) void sfz::Logger::setPrefix(absl::string_view prefix)
{ {
this->prefix = prefix; this->prefix = std::string(prefix);
} }
void sfz::Logger::clear() void sfz::Logger::clear()
{ {
clearFlag.clear(); clearFlag.clear();
prefix.clear();
} }
void sfz::Logger::moveEvents() noexcept void sfz::Logger::moveEvents() noexcept
@ -143,8 +142,9 @@ void sfz::Logger::moveEvents() noexcept
} }
} }
void sfz::Logger::enableLogging() void sfz::Logger::enableLogging(absl::string_view prefix)
{ {
setPrefix(prefix);
loggingEnabled = true; loggingEnabled = true;
} }

View file

@ -99,7 +99,7 @@ public:
* *
* @param prefix * @param prefix
*/ */
void setPrefix(const std::string& prefix); void setPrefix(absl::string_view prefix);
/** /**
* @brief Removes all logged data * @brief Removes all logged data
@ -111,7 +111,7 @@ public:
* @brief Enables logging and writing to log files on destruction * @brief Enables logging and writing to log files on destruction
* *
*/ */
void enableLogging(); void enableLogging(absl::string_view prefix);
/** /**
* @brief Disables logging and writing to log files on destruction * @brief Disables logging and writing to log files on destruction

View file

@ -291,7 +291,6 @@ bool sfz::Synth::loadSfzFile(const fs::path& file)
return false; return false;
resources.filePool.setRootDirectory(this->originalDirectory); resources.filePool.setRootDirectory(this->originalDirectory);
resources.logger.setPrefix(file.filename().string());
auto currentRegion = regions.begin(); auto currentRegion = regions.begin();
auto lastRegion = regions.rbegin(); auto lastRegion = regions.rbegin();
@ -953,9 +952,14 @@ bool sfz::Synth::shouldReloadFile()
return (checkModificationTime() > modificationTime); return (checkModificationTime() > modificationTime);
} }
void sfz::Synth::enableLogging() noexcept void sfz::Synth::enableLogging(absl::string_view prefix) noexcept
{ {
resources.logger.enableLogging(); resources.logger.enableLogging(prefix);
}
void sfz::Synth::setLoggingPrefix(absl::string_view prefix) noexcept
{
resources.logger.setPrefix(prefix);
} }
void sfz::Synth::disableLogging() noexcept void sfz::Synth::disableLogging() noexcept

View file

@ -355,7 +355,13 @@ public:
* many outputs so use with caution. * many outputs so use with caution.
* *
*/ */
void enableLogging() noexcept; void enableLogging(absl::string_view prefix = "") noexcept;
/**
* @brief Enable logging of timings to sidecar CSV files. This can produce
* many outputs so use with caution.
*
*/
void setLoggingPrefix(absl::string_view prefix) noexcept;
/** /**
* @brief Disable logging; * @brief Disable logging;
* *

View file

@ -191,6 +191,16 @@ void sfz::Sfizz::enableLogging() noexcept
synth->enableLogging(); synth->enableLogging();
} }
void sfz::Sfizz::enableLogging(const std::string& prefix) noexcept
{
synth->enableLogging(prefix);
}
void sfz::Sfizz::setLoggingPrefix(const std::string& prefix) noexcept
{
synth->setLoggingPrefix(prefix);
}
void sfz::Sfizz::disableLogging() noexcept void sfz::Sfizz::disableLogging() noexcept
{ {
synth->disableLogging(); synth->disableLogging();

View file

@ -238,6 +238,12 @@ void sfizz_enable_logging(sfizz_synth_t* synth)
return self->enableLogging(); return self->enableLogging();
} }
void sfizz_set_logging_prefix(sfizz_synth_t* synth, const char* prefix)
{
auto self = reinterpret_cast<sfz::Synth*>(synth);
return self->setLoggingPrefix(prefix);
}
void sfizz_disable_logging(sfizz_synth_t* synth) void sfizz_disable_logging(sfizz_synth_t* synth)
{ {
auto self = reinterpret_cast<sfz::Synth*>(synth); auto self = reinterpret_cast<sfz::Synth*>(synth);