15 #ifndef INCLUDED_basic_Tracer_hh
16 #define INCLUDED_basic_Tracer_hh
49 template <
class CharT,
class Traits = std::
char_traits<CharT> >
55 template <
class _CharT,
class _Traits = std::
char_traits<_CharT> >
81 return buf->str().size() == 0;
89 virtual void t_flush(std::string
const &) { assert(
"basic_otstream::t_flush"); };
142 bool muted_by_default
149 std::string
const & channel =
"",
151 bool muted_by_default =
false
156 std::string
const & channel,
157 std::string
const & channel_color,
158 std::string
const & channel_name_color =
"",
160 bool muted_by_default =
false
193 bool visible(
int priority )
const;
244 virtual void t_flush( std::string
const & );
271 virtual void t_flush(std::string
const &);
288 std::string
const ch,
299 template <
class out_stream>
310 std::string
const & channel,
315 bool muted_by_default
415 virtual void t_flush(std::string
const &);
426 if( TR.
visible() ) { t << entry; }
432 Tracer::TracerProxy &
operator <<( Tracer::TracerProxy &
TR,
T const & entry ) {
434 if( TR.visible() ) { t << entry; }
442 #endif // INCLUDED_basic_tracer_hh
bool visible_
is channel visible?
Base class for Tracer, TracerProxy and UTracer objects.
int priority() const
get/set tracer priority level.
Class to hold all Terminal ASCII codes as static data for CSI_Sequence. Note: that on non-tty termina...
static utility::CSI_Sequence bgCyan
std::string channel_
We need to copy channel name here so we can generate appropriate 'warning' message in destructor...
static utility::CSI_Sequence Cyan
static void safe_output(std::string const &)
Output a message in a manner that is safe if the Tracers/output are poorly initialized.
bool is_flushed() const
Return true if inner string buffer is empty.
void prepend_channel_name(out_stream &sout, std::string const &str)
static utility::CSI_Sequence Red
bool visibility_calculated_
is channel visibility already calculated?
static void flush_all_tracers()
static utility::CSI_Sequence bgBlack
int priority_
channel output priority level
virtual void t_flush(std::string const &)
overload member function.
utility::vector1< std::string > levels
list of muted channels
ReferenceCount base class – dispatch class.
int level
system priority level
void calculate_visibility()
determine the visibility of the proxy
static bool & ios_hook_raw_()
should the ios_hook_ the raw output?
TracerPriority
Priority levels for T() and Tracer object, modeled on the log4j project and its offspring. Priorities in Tracer are still ints so users can pass other arbitrary integer values (for now).
static void set_new_final_stream(std::ostream *new_final_stream)
static THREAD_LOCAL basic::Tracer TR("basic.execute")
static void set_default_final_stream()
bool timestamp
should a timestamp be added to the channel name?
static void super_mute(bool f)
static bool in(utility::vector1< std::string > const &, std::string const channel, bool strict)
return true if channel is inside vector, some logic apply.
Special PyRosetta friendly Tracer like buffer. Use it to capture Tracer output with set_ios_hook...
virtual ~basic_tstringbuf()
static bool initial_tracers_visibility_calculated_
std::vector< Tracer * > & all_tracers()
bool muted_
is channel muted ?
basic_tstringbuf(basic_otstream *ot)
static utility::CSI_Sequence bgRed
Tracer & T(std::string const &channel, TracerPriority priority)
T is special function for assign tracer property on the static object.
static utility::vector1< std::string > monitoring_list_
list of channels for which outout should be redirected.
void flush_all_channels()
flush tracer buffer and flush buffers of all sub-channels ie: Fatal, Error, Warning, Info, Debug, Trace
bool visibility_calculated() const
Adding this function to get around unused class data member warnings; you should never have to worry ...
static bool & super_mute_()
global super mute flag that allow to mute all io no matter what.
File to provide backwards compatibility for the thread_local keyword.
std::string channel_name_color_
Base class for reference-counted polymorphic classes.
TracerProxy(Tracer &tracer, int priority, std::string const &channel)
virtual void t_flush(std::string const &)
Flush inner buffer: send it to bound Tracer object, and clean it.
static utility::CSI_Sequence Underline
std::string const & channel_color()
Tracer & Error(TracerPriority priority=t_error)
Predefined Error tracer.
void init(std::string const &channel, std::string const &channel_color, std::string 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 constru...
static utility::CSI_Sequence White
std::string const & channel_name_color()
static utility::CSI_Sequence Reset
static otstreamOP & ios_hook()
link to Tracer like object where all output for selecting channels should go.
static bool super_mute()
global super mute flag that allow to mute all io no matter what.
bool visible() const
Is this tracer currently visible?.
static utility::CSI_Sequence Magenta
std::string const & channel() const
static utility::CSI_Sequence Yellow
static utility::CSI_Sequence bgBlue
utility::pointer::shared_ptr< otstream > otstreamOP
static utility::CSI_Sequence Bold
static OstreamPointer & final_stream()
set ios hook for final tracer stream (deafult is std::cout).
data structure to store all system level options for Tracer system.
Tracer(std::string const &channel="", TracerPriority priority=t_info, bool muted_by_default=false)
Create Tracer object with given channel and priority.
utility::vector1< std::string > muted
list of muted channels
Small inner class acting as a proxy to an object that hold it.
static utility::CSI_Sequence Blue
Tracer & Warning(TracerPriority priority=t_warning)
Predefined Warning tracer.
bool print_channel_name
should channel name be printed during the IO?
static void register_tracer(Tracer *tracer)
Tracers must register themselves with the static array of all tracers so that they can be flushed en ...
bool begining_of_the_line_
is current printing position a begining of the line?
static utility::CSI_Sequence bgWhite
static utility::CSI_Sequence bgYellow
static TracerManager * instance_
static TracerManager * get_instance()
void channel_color(std::string const &color)
std::string channel_color_
default colors for tracer output and tracer channel-name string (ie color of string such as: 'core...
static int mpi_rank_
Mpi rank is this process
std::ostream & operator<<(std::ostream &out, const JobOptions &job_options)
This output-operator function invokes the JobOption's show() method.
static utility::CSI_Sequence Black
void channel_name_color(std::string const &color)
virtual ~basic_otstream()
vector1: std::vector with 1-based indexing
std::ostream * OstreamPointer
void calculate_visibility()
calcualte visibility of the current object depending of the channel name and priority.
static void set_ios_hook(otstreamOP tr, std::string const &monitoring_channels_list, bool raw=true)
set ios hook for all tracer io operation.
static std::string const & get_all_channels_string()
virtual void t_flush(std::string const &)
overload member function.
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.
NumericTraits< Type > Traits
Tracer & operator()(int priority)
basic_otstream * otsream_
Class for handling user debug/warnings/errors. Use instance of this class instead of 'std::cout' for ...
TracerProxy Fatal
channels with predefined priority levels.
static utility::CSI_Sequence Green
friend Tracer & T(std::string const &, TracerPriority)
T is special function for assign tracer property on the static object.
virtual void t_flush(std::string const &)
notification that flush function was called and inner buffer should be outputed. This is the mechanim...
utility::vector1< std::string > unmuted
list of unmuted channels
std::string channel_
Data members.
Simple singleton class to hold the all_tracers_ array, which otherwise suffers from funky double-cons...
bool visibility_calculated() const
Adding this function to get around unused class data member warnings; you should never have to worry ...
THREAD_LOCAL basic::Tracer tr("struc_set_fragment_picker")
static TracerOptions tracer_options_
global option collection for Tracer IO.
static utility::CSI_Sequence bgGreen
std::vector< Tracer * > all_tracers_
bool visible_
is channel visible?
static void calculate_tracer_visibilities()
This function should be invoked after the options system has been initialized, so that the visibility...
basic_otstream< char > otstream
bool visibility_calculated_
is channel visibility already calculated?
static utility::CSI_Sequence bgMagenta
bool muted_by_default_
is channel muted by default?
virtual void output_callback(std::string)=0
static TracerOptions & tracer_options()
get/set tracer options - global options for Tracer IO.
int mute_level_
channel muted priority level (above which level is channel muted), calculated using user suppied -lev...