Rosetta
|
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for all your regular io. Channel argument must be related to the location of the source file. For example if you create Tracer object in src/basic/scoring/myfile.cc, then channel must be something like 'src.basic.scoring.myfile'. More...
#include <TracerImpl.hh>
Classes | |
class | TracerProxyImpl |
Small inner class acting as a proxy to an object that hold it. More... | |
Public Types | |
typedef std::ostream * | OstreamPointer |
Public Member Functions | |
TracerImpl (std::string const &channel="", TracerPriority priority=t_info, bool muted_by_default=false) | |
Create Tracer object with given channel and priority. More... | |
TracerImpl (std::string const &channel, utility::CSI_Sequence const &channel_color, utility::CSI_Sequence const &channel_name_color=utility::CSI_Nothing(), TracerPriority priority=t_info, bool muted_by_default=false) | |
Create Tracer object with channel color, channel name color and given channel and priority. More... | |
~TracerImpl () override | |
void | init (TracerImpl const &tr) |
re-init using data from another tracer object. More... | |
void | flush_all_channels () |
flush tracer buffer and flush buffers of all sub-channels ie: Fatal, Error, Warning, Info, Debug, Trace More... | |
bool | visible () |
Is this tracer currently visible?. More... | |
bool | visible (int priority) |
is this tracer visible, if it used the given priority value? More... | |
int | priority () const |
get/set tracer priority level. More... | |
TracerImpl & | operator() (int priority) |
void | priority (int priority) |
std::string const & | channel () const |
utility::CSI_Sequence const & | channel_color () |
Get the channel color. More... | |
void | channel_color (utility::CSI_Sequence const &color) |
Set the channel color. More... | |
utility::CSI_Sequence const & | channel_name_color () |
void | channel_name_color (utility::CSI_Sequence const &color) |
void | set_local_print_channel_name (bool const setting) |
Set whether we're printing the channel name. More... | |
bool | get_local_print_channel_name () const |
Get whether we're printing the channel name. More... | |
TracerProxyImpl & | get_proxy_by_priority (TracerPriority priority) |
![]() | |
basic_otstream () | |
~basic_otstream () override | |
bool | is_flushed () const |
Return true if inner string buffer is empty. More... | |
Static Public Member Functions | |
static void | set_new_final_stream (std::ostream *new_final_stream) |
set ios hook for final tracer stream (deafult is std::cout). More... | |
static void | set_default_final_stream () |
static void | set_ios_hook (otstreamOP tr, std::string const &monitoring_channels_list, bool raw=false) |
set ios hook for all tracer io operation. More... | |
static std::string const & | get_all_channels_string () |
static void | set_tracer_options (TracerOptions const &to) |
set tracer options - global options for Tracer IO. More... | |
static bool | super_mute () |
global super mute flag that allow to mute all io no matter what. More... | |
static void | super_mute (bool f) |
static void | output_prefix (std::string const &) |
set/get globale string-prefix for all Tracer output strings More... | |
static std::string | output_prefix () |
Public Attributes | |
TracerProxyImpl | Fatal |
channels with predefined priority levels. More... | |
TracerProxyImpl | Error |
TracerProxyImpl | Warning |
TracerProxyImpl | Info |
TracerProxyImpl | Debug |
TracerProxyImpl | Trace |
Static Public Attributes | |
static utility::CSI_Sequence | Reset |
static utility::CSI_Sequence | Bold |
static utility::CSI_Sequence | Underline |
static utility::CSI_Sequence | Black |
static utility::CSI_Sequence | Red |
static utility::CSI_Sequence | Green |
static utility::CSI_Sequence | Yellow |
static utility::CSI_Sequence | Blue |
static utility::CSI_Sequence | Magenta |
static utility::CSI_Sequence | Cyan |
static utility::CSI_Sequence | White |
static utility::CSI_Sequence | bgBlack |
static utility::CSI_Sequence | bgRed |
static utility::CSI_Sequence | bgGreen |
static utility::CSI_Sequence | bgYellow |
static utility::CSI_Sequence | bgBlue |
static utility::CSI_Sequence | bgMagenta |
static utility::CSI_Sequence | bgCyan |
static utility::CSI_Sequence | bgWhite |
Protected Member Functions | |
void | t_flush (std::string const &) override |
overload member function. More... | |
Private Member Functions | |
void | init (std::string const &channel, utility::CSI_Sequence const &channel_color, utility::CSI_Sequence const &channel_name_color, TracerPriority priority, bool muted_by_default) |
init Tracer object with given parameters. This is a helper function to be called from various constructors More... | |
TracerImpl (TracerImpl const &tr)=delete | |
copy constructor. More... | |
template<class out_stream > | |
void | prepend_channel_name (out_stream &sout, std::string const &str) |
helper function for t_flush() – do not call from elsewhere (without caution) More... | |
void | calculate_visibility () |
calculate visibility of the current object depending of the channel name and priority. More... | |
Static Private Member Functions | |
static OstreamPointer & | final_stream () |
static bool | in (utility::vector1< std::string > const &, std::string const &channel, bool strict) |
return true if channel is inside vector, some logic apply. More... | |
static bool | calculate_tracer_level (utility::vector1< std::string > const &v, std::string const &ch, bool strict, int &res) |
calculate channel priority with hierarchy in mind. More... | |
static void | calculate_visibility (std::string const &channel, int priority, bool &visible, bool &muted, int &mute_level_, bool muted_by_default) |
static void | safe_output (std::string const &) |
Output a message in a manner that is safe if the Tracers/output are poorly initialized. More... | |
static otstreamOP & | ios_hook () |
link to Tracer like object where all output for selecting channels should go. More... | |
static utility::vector1< std::string > & | monitoring_list_ () |
list of channels for which outout should be redirected. More... | |
static bool & | super_mute_ () |
global super mute flag that allow to mute all io no matter what. More... | |
Private Attributes | |
std::string | channel_ |
Data members. More... | |
bool | local_print_channel_name_ |
Allows local override of whether channel name is printed. This is true by default, in which case the global setting is used. Setting this to false prevents channel name from being printed for this tracer only. More... | |
utility::CSI_Sequence | channel_color_ |
default colors for tracer output and tracer channel-name string (ie color of string such as: 'core.pose:') More... | |
utility::CSI_Sequence | channel_name_color_ |
int | priority_ = t_info |
channel output priority level More... | |
int | mute_level_ = t_info |
channel muted priority level (above which level is channel muted), calculated using user suppied -level and -levels options More... | |
bool | visible_ = true |
is channel visible? More... | |
bool | muted_ = false |
is channel muted ? More... | |
bool | muted_by_default_ = false |
is channel muted by default? More... | |
Static Private Attributes | |
static TracerOptionsOP | tracer_options_ |
global option collection for Tracer IO. More... | |
static int | mpi_rank_ |
@which Mpi rank is this process More... | |
static std::string | output_prefix_ |
global prefix for all tracer output More... | |
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for all your regular io. Channel argument must be related to the location of the source file. For example if you create Tracer object in src/basic/scoring/myfile.cc, then channel must be something like 'src.basic.scoring.myfile'.
typedef std::ostream* basic::TracerImpl::OstreamPointer |
basic::TracerImpl::TracerImpl | ( | std::string const & | channel = "" , |
TracerPriority | priority = t_info , |
||
bool | muted_by_default = false |
||
) |
Create Tracer object with given channel and priority.
Constructor of Tracer object. Since most of the Tracer object will be created as static - they Constuctor will be called before Option system is initialized. So we can't really calculate any vizibility or priority here. Such calculation should be done later, whe first IO operation happend.
References channel(), utility::CSI_Nothing(), init(), and priority().
basic::TracerImpl::TracerImpl | ( | std::string const & | channel, |
utility::CSI_Sequence const & | channel_color, | ||
utility::CSI_Sequence const & | channel_name_color = utility::CSI_Nothing() , |
||
TracerPriority | priority = t_info , |
||
bool | muted_by_default = false |
||
) |
Create Tracer object with channel color, channel name color and given channel and priority.
Ex: static basic::Tracer Blue("blue", CSI_Blue());
References channel(), channel_color(), channel_name_color(), init(), and priority().
|
override |
References Debug, Error, Fatal, create_a3b_hbs::i, Info, Trace, kmeans_adaptive_kernel_density_bb_dependent_rotlib::v, and Warning.
|
privatedelete |
copy constructor.
Functions
|
staticprivate |
calculate channel priority with hierarchy in mind.
Same as before but return integer value for matched channel or closest match (we asume that 'v' in levels format, ie like: <channel name>:level )
References kmeans_adaptive_kernel_density_bb_dependent_rotlib::flag, create_a3b_hbs::i, ObjexxFCL::len(), ObjexxFCL::lowercased(), res, docking::s, safe_output(), subloop_histogram::size, utility::string2int(), utility::string_split(), basic::t_debug, basic::t_error, basic::t_fatal, basic::t_info, basic::t_trace, basic::t_warning, and kmeans_adaptive_kernel_density_bb_dependent_rotlib::v.
Referenced by calculate_visibility().
|
private |
calculate visibility of the current object depending of the channel name and priority.
Calculate visibility of current Tracer object and all of its proxies
References basic::TracerImpl::TracerProxyImpl::calculate_visibility(), channel_, utility::io::oc::cout, Debug, Error, Fatal, Info, mute_level_, muted_, muted_by_default_, priority_, Trace, tracer_options_, visible_, and Warning.
Referenced by basic::TracerImpl::TracerProxyImpl::calculate_visibility(), and init().
|
staticprivate |
Calculate visibility (static version) of current Tracer object using channel name and priority. result stored in 'muted' and 'visible'.
References calculate_tracer_level(), channel(), in(), utility::mpi_nprocs(), utility::mpi_rank(), mpi_rank_, priority(), tracer_options_, and visible().
|
inline |
References channel_.
Referenced by calculate_visibility(), basic::Tracer::channel(), init(), and TracerImpl().
|
inline |
|
inline |
Set the channel color.
This can be done in a stream like this: TR << TR.bgWhite << TR.Black << "Example" << TR.Reset << std::endl;
References channel_color_.
|
inline |
References channel_name_color_.
Referenced by init(), and TracerImpl().
|
inline |
References channel_name_color_.
|
staticprivate |
References utility::io::oc::cout.
Referenced by safe_output(), set_default_final_stream(), set_new_final_stream(), and t_flush().
void basic::TracerImpl::flush_all_channels | ( | ) |
flush tracer buffer and flush buffers of all sub-channels ie: Fatal, Error, Warning, Info, Debug, Trace
References Debug, Error, Fatal, create_a3b_hbs::i, Info, Trace, kmeans_adaptive_kernel_density_bb_dependent_rotlib::v, and Warning.
Referenced by basic::Tracer::flush_all_channels().
|
static |
Referenced by basic::Tracer::get_all_channels_string(), and t_flush().
|
inline |
Get whether we're printing the channel name.
This gets the local setting, but does not look at the global setting. (In practice, if the local setting is true then the global setting is used.)
References local_print_channel_name_.
Referenced by basic::Tracer::get_local_print_channel_name().
TracerImpl::TracerProxyImpl & basic::TracerImpl::get_proxy_by_priority | ( | TracerPriority | priority | ) |
References Debug, Error, Fatal, Info, priority(), basic::t_debug, basic::t_error, basic::t_fatal, basic::t_info, basic::t_warning, Trace, and Warning.
Referenced by basic::Tracer::TracerProxy::tracer_proxy_impl().
|
staticprivate |
return true if channel is inside vector, some logic apply.
Check if string representing channel 'ch' is in vector<string> v. Return true if channel is in vector, false otherwise. Two mode of operation: Strict: strict==true - channels compared verbatim. Regular: strict==false - comparing with hierarchy in mind, ie: ch='basic.pose' v[0]='basic' --> will yield true.
References create_a3b_hbs::i, docking::s, subloop_histogram::size, and kmeans_adaptive_kernel_density_bb_dependent_rotlib::v.
Referenced by calculate_visibility(), and t_flush().
|
private |
init Tracer object with given parameters. This is a helper function to be called from various constructors
References calculate_visibility(), channel(), channel_, channel_color(), channel_color_, channel_name_color(), channel_name_color_, local_print_channel_name_, mute_level_, muted_, muted_by_default_, priority(), priority_, and visible_.
Referenced by TracerImpl().
void basic::TracerImpl::init | ( | TracerImpl const & | tr | ) |
re-init using data from another tracer object.
re-init using data from another tracer object.
References calculate_visibility(), basic::Tracer::channel_, channel_, mute_level_, muted_, basic::Tracer::priority_, priority_, tr, and visible_.
|
staticprivate |
link to Tracer like object where all output for selecting channels should go.
static data members
References execute::hook.
Referenced by safe_output(), set_ios_hook(), and t_flush().
|
staticprivate |
list of channels for which outout should be redirected.
Referenced by set_ios_hook(), and t_flush().
TracerImpl & basic::TracerImpl::operator() | ( | int | priority | ) |
References priority().
|
static |
References output_prefix_.
|
static |
set/get globale string-prefix for all Tracer output strings
References output_prefix_.
|
private |
helper function for t_flush() – do not call from elsewhere (without caution)
Write the contents of str to sout prepending the channel name on each line if the print_channel_name flag is set.
References Bold, channel_, channel_color_, channel_name_color_, utility::SingletonBase< RosettaThreadManager >::get_instance(), local_print_channel_name_, mpi_rank_, output_prefix_, priority_, Red, Reset, str(), basic::t_error, basic::t_fatal, basic::t_warning, utility::timestamp(), basic::thread_manager::RosettaThreadManager::total_threads(), and tracer_options_.
|
inline |
get/set tracer priority level.
References priority_.
Referenced by calculate_visibility(), get_proxy_by_priority(), init(), operator()(), priority(), TracerImpl(), and visible().
void basic::TracerImpl::priority | ( | int | priority | ) |
References mute_level_, muted_, priority(), priority_, and visible_.
|
staticprivate |
Output a message in a manner that is safe if the Tracers/output are poorly initialized.
References utility::io::oc::cerr, final_stream(), ios_hook(), and pyrosetta.utility.array::message.
Referenced by calculate_tracer_level().
|
static |
References utility::io::oc::cout, and final_stream().
|
static |
set ios hook for all tracer io operation.
monitoring_channels_list | is space separated list of channels.i |
raw | is ignored |
Set OStringStream object to which all Tracers output listed in the monitoring_channels_list should be copied.
The boolean parameter is left for backward compatibility. (It used to control the ability to ignore visibility settings.)
References ios_hook(), monitoring_list_(), utility::split(), tr, and utility_exit_with_message.
Referenced by pyrosetta.logging_support.PythonLoggingSink::__del__(), test.T007_TracerIO.MyPyTracer::__del__(), and basic::Tracer::set_ios_hook().
void basic::TracerImpl::set_local_print_channel_name | ( | bool const | setting | ) |
Set whether we're printing the channel name.
This overrides the local setting, but does not alter the global setting.
References local_print_channel_name_.
Referenced by basic::Tracer::set_local_print_channel_name().
|
static |
set ios hook for final tracer stream (deafult is std::cout).
References final_stream(), and utility_exit_with_message.
|
static |
set tracer options - global options for Tracer IO.
References utility::io::oc::cout, and tracer_options_.
|
inlinestatic |
global super mute flag that allow to mute all io no matter what.
References super_mute_().
Referenced by basic::Tracer::super_mute().
|
inlinestatic |
References create_a3b_hbs::f, and super_mute_().
|
staticprivate |
global super mute flag that allow to mute all io no matter what.
References basic::options::OptionKeys::out::mute.
Referenced by super_mute(), and t_flush().
|
overrideprotectedvirtual |
overload member function.
Inform Tracer that is contents was modified, and IO is in order.
Reimplemented from basic::basic_otstream< CharT, Traits >.
References channel_, final_stream(), get_all_channels_string(), in(), ios_hook(), monitoring_list_(), str(), super_mute_(), and visible().
Referenced by basic::MemTracerImpl::t_flush().
|
inline |
Is this tracer currently visible?.
References visible_.
Referenced by calculate_visibility(), basic::MemTracerImpl::t_flush(), t_flush(), and basic::Tracer::visible().
bool basic::TracerImpl::visible | ( | int | priority | ) |
is this tracer visible, if it used the given priority value?
References mute_level_, muted_, and priority().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Referenced by prepend_channel_name().
|
private |
Data members.
channel name
Referenced by basic::TracerImpl::TracerProxyImpl::calculate_visibility(), calculate_visibility(), channel(), init(), prepend_channel_name(), and t_flush().
|
private |
default colors for tracer output and tracer channel-name string (ie color of string such as: 'core.pose:')
Referenced by channel_color(), init(), and prepend_channel_name().
|
private |
Referenced by channel_name_color(), init(), and prepend_channel_name().
|
static |
TracerProxyImpl basic::TracerImpl::Debug |
Referenced by calculate_visibility(), flush_all_channels(), get_proxy_by_priority(), and ~TracerImpl().
TracerProxyImpl basic::TracerImpl::Error |
Referenced by calculate_visibility(), flush_all_channels(), get_proxy_by_priority(), and ~TracerImpl().
TracerProxyImpl basic::TracerImpl::Fatal |
channels with predefined priority levels.
Referenced by calculate_visibility(), flush_all_channels(), get_proxy_by_priority(), and ~TracerImpl().
|
static |
TracerProxyImpl basic::TracerImpl::Info |
Referenced by calculate_visibility(), flush_all_channels(), get_proxy_by_priority(), and ~TracerImpl().
|
private |
Allows local override of whether channel name is printed. This is true by default, in which case the global setting is used. Setting this to false prevents channel name from being printed for this tracer only.
Referenced by get_local_print_channel_name(), init(), prepend_channel_name(), and set_local_print_channel_name().
|
static |
|
staticprivate |
@which Mpi rank is this process
Referenced by calculate_visibility(), and prepend_channel_name().
|
private |
channel muted priority level (above which level is channel muted), calculated using user suppied -level and -levels options
Referenced by calculate_visibility(), init(), priority(), and visible().
|
private |
is channel muted ?
Referenced by calculate_visibility(), init(), priority(), and visible().
|
private |
is channel muted by default?
Referenced by calculate_visibility(), and init().
|
staticprivate |
global prefix for all tracer output
Referenced by output_prefix(), and prepend_channel_name().
|
private |
channel output priority level
Referenced by basic::TracerImpl::TracerProxyImpl::calculate_visibility(), calculate_visibility(), init(), prepend_channel_name(), priority(), and basic::TracerImpl::TracerProxyImpl::t_flush().
|
static |
Referenced by prepend_channel_name().
|
static |
Static objects holding various ASCII CSI codes (see utility/CSI_Sequence.hh)
Referenced by prepend_channel_name().
TracerProxyImpl basic::TracerImpl::Trace |
Referenced by calculate_visibility(), flush_all_channels(), get_proxy_by_priority(), and ~TracerImpl().
|
staticprivate |
global option collection for Tracer IO.
Referenced by calculate_visibility(), prepend_channel_name(), and set_tracer_options().
|
static |
|
private |
is channel visible?
Referenced by basic::TracerImpl::TracerProxyImpl::calculate_visibility(), calculate_visibility(), init(), priority(), and visible().
TracerProxyImpl basic::TracerImpl::Warning |
Referenced by calculate_visibility(), flush_all_channels(), get_proxy_by_priority(), and ~TracerImpl().
|
static |
|
static |