FFmpegfs Fuse Multi Media Filesystem 2.14
|
#include <logging.h>
Classes | |
class | Logger |
Logging helper class. More... | |
Public Types | |
enum class | LOGLEVEL { LOGERROR = 1 , LOGWARN = 2 , LOGINFO = 3 , LOGDEBUG = 4 , LOGTRACE = 5 } |
Logging level types enum. More... | |
Public Member Functions | |
Logging (const std::string &logfile, LOGLEVEL max_level, bool to_stderr, bool to_syslog) | |
bool | GetFail () const |
Check whether either failbit or badbit is set. More... | |
Static Public Member Functions | |
static bool | init_logging (const std::string &logfile, LOGLEVEL max_level, bool to_stderr, bool to_syslog) |
Initialise the logging facility. More... | |
template<typename T , typename... Args> | |
static void | trace (const T filename, const std::string &format_string, Args &&...args) |
Write trace level log entry. More... | |
template<typename T , typename... Args> | |
static void | debug (const T filename, const std::string &format_string, Args &&...args) |
Write debug level log entry. More... | |
template<typename T , typename... Args> | |
static void | info (const T filename, const std::string &format_string, Args &&...args) |
Write info level log entry. More... | |
template<typename T , typename... Args> | |
static void | warning (const T filename, const std::string &format_string, Args &&...args) |
Write warning level log entry. More... | |
template<typename T , typename... Args> | |
static void | error (const T filename, const std::string &format_string, Args &&...args) |
Write error level log entry. More... | |
static void | log_with_level (LOGLEVEL loglevel, const char *filename, const std::string &message) |
Write log entry. More... | |
static void | log_with_level (LOGLEVEL loglevel, const std::string &filename, const std::string &message) |
Write log entry. More... | |
static bool | show (LOGLEVEL loglevel) |
Check if log entry should be displayed at the current log level. More... | |
Protected Attributes | |
friend | Logger |
Make logger class our friend. More... | |
std::ofstream | m_logfile |
Log file object for writing to disk. More... | |
const LOGLEVEL | m_max_level |
The maximum level of log output to write. More... | |
const bool | m_to_stderr |
Whether to write log output to stderr. More... | |
const bool | m_to_syslog |
Whether to write log output to syslog. More... | |
Static Protected Attributes | |
static Logging * | m_logging |
Reference to self, Logging is a singleton. More... | |
static std::recursive_mutex | m_mutex |
Access mutex. More... | |
Static Private Member Functions | |
static std::string | format_helper (const std::string &string_to_update, const size_t __attribute__((unused)) index_to_replace) |
Standard format_helper without parameters. More... | |
template<typename T , typename... Args> | |
static std::string | format_helper (const std::string &string_to_search, const size_t index_to_replace, T &&val, Args &&...args) |
format_helper with variadic parameters. More... | |
template<typename... Args> | |
static std::string | format (const std::string &format_string, Args &&...args) |
format string with single token More... | |
Friends | |
Logger | Log (LOGLEVEL loglevel, const std::string &filename) |
Make logger class our friend for our constructor. More... | |
Logging facility
Within the log message text, escape sequences are supported for dynamically formatting the message.
Escape sequences have either the form n or %<format specifier>n, where the index n starts at 1.
The index specifies the position of the argument in the list. They can appear in any given order. An index can be used more than once, and not all indexes have to be present (in which case the argument will not be printed). The input value is automatically converted to string format and can be among std::string, char *, int, uint64_t and more.
The format specifier is the same as used in printf and sprintf.
Prints "Audio 2 channels 44100 KHz".
Prints "Audio stereo 44.100 KHz".
|
strong |
|
explicit |
Construct Logging object.
[in] | logfile | - The name of a file to write logging output to. If empty, no output will be written. |
[in] | max_level | - The maximum level of log output to write. |
[in] | to_stderr | - Whether to write log output to stderr. |
[in] | to_syslog | - Whether to write log output to syslog. |
Definition at line 93 of file logging.cc.
References m_logfile, and m_to_syslog.
Referenced by init_logging().
|
inlinestatic |
Write debug level log entry.
[in] | filename | - Name of the file for which this log entry was written. May be empty. |
[in] | format_string | - Format a string in FFmpegfs logger format. |
[in] | args | - 0 or more format arguments. See format. |
Definition at line 182 of file logging.h.
References format_helper(), log_with_level(), LOGDEBUG, and show().
Referenced by FFmpeg_Transcoder::add_albumart_stream(), FFmpeg_Transcoder::add_external_subtitle_stream(), FFmpeg_Transcoder::add_stream(), FFmpeg_Transcoder::add_subtitle_stream(), FFmpeg_Base::audio_info(), FFmpeg_Transcoder::can_copy_stream(), create_dvd_virtualfile(), FFmpeg_Transcoder::decode_frame(), FFmpeg_Transcoder::decode_video_frame(), ffmpegfs_getattr(), ffmpegfs_readdir(), FFmpeg_Transcoder::get_hw_pix_fmt(), get_source_properties(), FFmpeg_Transcoder::init_deinterlace_filters(), FFmpeg_Transcoder::init_resampler(), FFmpeg_Transcoder::init_rescaler(), kick_next(), link_up(), Cache::load_index(), FFmpeg_Transcoder::open_bestmatch_video(), Buffer::open_file(), FFmpeg_Transcoder::open_input_file(), FFmpeg_Transcoder::open_output_file(), FFmpeg_Transcoder::open_output_filestreams(), FFmpeg_Transcoder::open_output_frame_set(), BlurayIO::openio(), DiskIO::openio(), DvdIO::openio(), Cache_Entry::outdated(), parse_bluray(), parse_dvd(), parse_file(), parse_vcd(), prepare_script(), FFmpeg_Base::subtitle_info(), thread_pool::tear_down(), transcode(), transcode_finish(), transcoder_free(), transcoder_init(), transcoder_new(), Cache::upgrade_db(), and FFmpeg_Base::video_info().
|
inlinestatic |
Write error level log entry.
[in] | filename | - Name of the file for which this log entry was written. May be empty. |
[in] | format_string | - Format a string in FFmpegfs logger format. |
[in] | args | - 0 or more format arguments. See format. |
Definition at line 239 of file logging.h.
References format_helper(), log_with_level(), LOGERROR, and show().
Referenced by FFmpeg_Transcoder::add_albumart_frame(), FFmpeg_Transcoder::add_albumart_stream(), FFmpeg_Transcoder::add_external_subtitle_stream(), FFmpeg_Transcoder::add_external_subtitle_streams(), FFmpeg_Transcoder::add_samples_to_fifo(), FFmpeg_Transcoder::add_stream(), FFmpeg_Transcoder::add_stream_copy(), FFmpeg_Transcoder::add_subtitle_stream(), FFmpeg_Transcoder::alloc_picture(), audio_stream_info(), Cache::begin_transaction(), check_cuesheet(), Cache::check_min_version(), Buffer::clear(), Cache::column_exists(), FFmpeg_Transcoder::convert_samples(), Buffer::copy(), FFmpeg_Transcoder::create_audio_frame(), create_bluray_virtualfile(), create_cuesheet_virtualfile(), create_dvd_virtualfile(), Cache::create_table_cache_entry(), create_vcd_virtualfile(), FFmpeg_Transcoder::decode(), FFmpeg_Transcoder::decode_audio_frame(), FFmpeg_Transcoder::decode_frame(), FFmpeg_Transcoder::decode_subtitle(), FFmpeg_Transcoder::decode_video_frame(), FFmpeg_Base::dict_set_with_check(), FFmpeg_Transcoder::encode_audio_frame(), FFmpeg_Transcoder::encode_image_frame(), FFmpeg_Transcoder::encode_subtitle(), FFmpeg_Transcoder::encode_video_frame(), Cache::end_transaction(), ffmpegfs_fgetattr(), ffmpegfs_read(), ffmpegfs_readdir(), ffmpegfs_release(), find_original(), Buffer::flush(), FFmpeg_Transcoder::flush_delayed_audio(), FFmpeg_Transcoder::flush_delayed_video(), FFmpeg_Transcoder::foreach_subtitle_file(), FFmpeg_Transcoder::get_format(), FFmpeg_Transcoder::get_hw_pix_fmt(), FFmpeg_Transcoder::hwdevice_ctx_add_ref(), FFmpeg_Transcoder::hwdevice_ctx_create(), FFmpeg_Transcoder::hwframe_copy_from_hw(), FFmpeg_Transcoder::hwframe_copy_to_hw(), FFmpeg_Transcoder::hwframe_ctx_set(), Buffer::init(), FFmpeg_Transcoder::init_audio_fifo(), FFmpeg_Transcoder::init_audio_output_frame(), FFmpeg_Transcoder::init_converted_samples(), FFmpeg_Transcoder::init_deinterlace_filters(), FFmpeg_Transcoder::init_resampler(), FFmpeg_Transcoder::init_rescaler(), FFmpeg_Transcoder::input_read(), link_down(), link_up(), Cache::load_index(), Buffer::map_file(), FFmpeg_Transcoder::open_albumarts(), FFmpeg_Transcoder::open_bestmatch_audio(), FFmpeg_Transcoder::open_bestmatch_decoder(), FFmpeg_Transcoder::open_bestmatch_video(), FFmpeg_Transcoder::open_decoder(), FFmpeg_Transcoder::open_input_file(), FFmpeg_Transcoder::open_output_file(), FFmpeg_Transcoder::open_output_filestreams(), FFmpeg_Transcoder::open_output_frame_set(), FFmpeg_Transcoder::open_subtitles(), BlurayIO::openio(), DvdIO::openio(), FFmpeg_Base::opt_set_with_check(), FFmpeg_Transcoder::output_write(), parse_cuesheet(), parse_dvd(), parse_file(), Cache::prepare_stmts(), FFmpeg_Transcoder::process_single_fr(), FFmpeg_Transcoder::read_decode_convert_and_store(), Cache::read_info(), BlurayIO::readio(), DvdIO::readio(), Buffer::reserve(), Cache::rollback_transaction(), FFmpeg_Transcoder::seek(), FFmpeg_Transcoder::send_filters(), FFmpeg_Transcoder::skip_decoded_frames(), FFmpeg_Transcoder::stack_seek_frame(), FFmpeg_Transcoder::stack_seek_segment(), FFmpeg_Transcoder::start_new_segment(), start_timer(), stop_timer(), FFmpeg_Transcoder::store_packet(), Cache::table_exists(), transcoder_init(), transcoder_read_frame(), transcoder_set_filesize(), transcoder_thread(), Buffer::unmap_file(), Cache::upgrade_db(), video_stream_info(), FFmpeg_Transcoder::write_output_file_header(), and FFmpeg_Transcoder::write_output_file_trailer().
|
inlinestaticprivate |
format string with single token
[in] | format_string | - Format string to be searched. |
[in] | args | - arguments |
Definition at line 354 of file logging.h.
References format_helper().
|
inlinestaticprivate |
format_helper with variadic parameters.
Calls itself recursively until all tokens are replaced.
[in] | string_to_search | - format string to be searched. |
[in] | index_to_replace | - index number (n) to be replaced. May be present 0...x times. |
[in] | val | - Replacement value to fill in tokens. |
[in] | args | - Further arguments. |
Definition at line 300 of file logging.h.
References format_helper().
|
staticprivate |
Standard format_helper without parameters.
[in] | string_to_update | - Original string. |
[in] | index_to_replace | - unused |
Definition at line 236 of file logging.cc.
Referenced by debug(), error(), format(), format_helper(), info(), trace(), and warning().
bool Logging::GetFail | ( | ) | const |
Check whether either failbit or badbit is set.
Definition at line 200 of file logging.cc.
References m_logfile.
Referenced by init_logging().
|
inlinestatic |
Write info level log entry.
[in] | filename | - Name of the file for which this log entry was written. May be empty. |
[in] | format_string | - Format a string in FFmpegfs logger format. |
[in] | args | - 0 or more format arguments. See format. |
Definition at line 201 of file logging.h.
References format_helper(), log_with_level(), LOGINFO, and show().
Referenced by FFmpeg_Transcoder::can_copy_stream(), ffmpegfs_destroy(), ffmpegfs_init(), thread_pool::init(), link_down(), link_up(), maintenance_handler(), master_check(), FFmpeg_Transcoder::open_bestmatch_video(), FFmpeg_Transcoder::open_output(), FFmpeg_Transcoder::open_output_filestreams(), VcdIO::openio(), FFmpeg_Transcoder::start_new_segment(), stop_timer(), transcode(), transcode_until(), transcoder_thread(), and Cache::upgrade_db().
|
static |
Initialise the logging facility.
[in] | logfile | - The name of a file to write logging output to. If empty, no output will be written. |
[in] | max_level | - The maximum level of log output to write. |
[in] | to_stderr | - Whether to write log output to stderr. |
[in] | to_syslog | - Whether to write log output to syslog. |
Definition at line 210 of file logging.cc.
References GetFail(), Logging(), and m_logging.
Referenced by init_logging().
|
static |
Write log entry.
[in] | loglevel | - The level of log this message is for. |
[in] | filename | - Name of the file for which this log entry was written. May be nullptr. |
[in] | message | - Message to log. |
Definition at line 226 of file logging.cc.
References log_with_level().
Referenced by debug(), error(), ffmpeg_log(), info(), log_with_level(), trace(), and warning().
|
static |
Write log entry.
[in] | loglevel | - The level of log this message is for. |
[in] | filename | - Name of the file for which this log entry was written. May be empty. |
[in] | message | - Message to log. |
Definition at line 231 of file logging.cc.
References Log.
|
inlinestatic |
Check if log entry should be displayed at the current log level.
[in] | loglevel | - Log level of log entry. |
Definition at line 272 of file logging.h.
References m_logging, and m_max_level.
Referenced by debug(), error(), ffmpeg_log(), info(), trace(), and warning().
|
inlinestatic |
Write trace level log entry.
[in] | filename | - Name of the file for which this log entry was written. May be empty. |
[in] | format_string | - Format a string in FFmpegfs logger format. |
[in] | args | - 0 or more format arguments. See format. |
Definition at line 163 of file logging.h.
References format_helper(), log_with_level(), LOGTRACE, and show().
Referenced by FFmpeg_Transcoder::add_albumart_frame(), FFmpeg_Transcoder::add_stream(), Cache_Entry::Cache_Entry(), check_bluray(), check_cuesheet(), check_dvd(), check_vcd(), Buffer::close_file(), FFmpeg_Transcoder::closeio(), Cache::closeio(), create_bluray_virtualfile(), create_dvd_virtualfile(), FFmpeg_Transcoder::encode_video_frame(), FFmpeg_Transcoder::FFmpeg_Transcoder(), ffmpegfs_fgetattr(), ffmpegfs_getattr(), ffmpegfs_open(), ffmpegfs_read(), ffmpegfs_readdir(), ffmpegfs_readlink(), ffmpegfs_release(), ffmpegfs_statfs(), get_format(), FFmpeg_Transcoder::init_rescaler(), thread_pool::loop_function(), Buffer::map_file(), master_check(), FFmpeg_Transcoder::open_albumarts(), FFmpeg_Transcoder::open_bestmatch_video(), Buffer::open_file(), Cache_Entry::openio(), Cache::openio(), DvdIO::openio(), parse_bluray(), parse_cuesheet_file(), parse_cuesheet_text(), parse_dvd(), parse_file(), prepare_script(), print_params(), FFmpeg_Transcoder::process_metadata(), FFmpeg_Transcoder::read_decode_convert_and_store(), Buffer::reallocate(), thread_pool::schedule_thread(), start_timer(), FFmpeg_Transcoder::store_packet(), transcode_until(), transcoder_new(), transcoder_predict_filesize(), transcoder_read(), transcoder_read_frame(), transcoder_set_filesize(), Buffer::unmap_file(), FFmpeg_Transcoder::update_codec(), FFmpeg_Transcoder::update_format(), Cache_Entry::~Cache_Entry(), and FFmpeg_Transcoder::~FFmpeg_Transcoder().
|
inlinestatic |
Write warning level log entry.
[in] | filename | - Name of the file for which this log entry was written. May be empty. |
[in] | format_string | - Format a string in FFmpegfs logger format. |
[in] | args | - 0 or more format arguments. See format. |
Definition at line 220 of file logging.h.
References format_helper(), log_with_level(), LOGWARN, and show().
Referenced by FFmpeg_Transcoder::calculate_predicted_filesize(), FFmpeg_Transcoder::encode_video_frame(), Cache::load_index(), FFmpeg_Transcoder::open_input_file(), BlurayIO::openio(), parse_dvd(), prepare_script(), FFmpeg_Transcoder::purge(), DvdIO::readio(), Buffer::remove_file(), FFmpeg_Transcoder::send_filters(), sighandler(), transcode_until(), transcoder_read_frame(), transcoder_set_filesize(), transcoder_thread(), and FFmpeg_Base::video_stream_setup().
|
friend |
Make logger class our friend for our constructor.
[in] | loglevel | - The level of log this message is for. |
[in] | filename | - Name of the file for which this log entry was written. May be empty. |
Definition at line 205 of file logging.cc.
Referenced by log_with_level().
|
protected |
|
protected |
Log file object for writing to disk.
Definition at line 370 of file logging.h.
Referenced by GetFail(), Logging(), and Logging::Logger::~Logger().
|
staticprotected |
Reference to self, Logging is a singleton.
Definition at line 368 of file logging.h.
Referenced by init_logging(), show(), and Logging::Logger::~Logger().
|
protected |
|
staticprotected |
|
protected |
Whether to write log output to stderr.
Definition at line 372 of file logging.h.
Referenced by Logging::Logger::~Logger().
|
protected |
Whether to write log output to syslog.
Definition at line 373 of file logging.h.
Referenced by Logging(), and Logging::Logger::~Logger().