Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
basic::Tracer Class Reference

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 'basic.scoring.myfile'. More...

#include <Tracer.hh>

Inheritance diagram for basic::Tracer:
Inheritance graph
[legend]

Classes

class  TracerProxy
 

Public Member Functions

 Tracer (std::string const &channel="", TracerPriority priority=t_info, bool muted_by_default=false)
 Create Tracer object with given channel and priority. More...
 
 Tracer (std::string const &channel, utility::CSI::CSI_Enum const &channel_color, utility::CSI::CSI_Enum 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...
 
virtual ~Tracer ()
 
 Tracer (Tracer const &)=delete
 
Traceroperator= (Tracer const &)=delete
 
template<typename T >
TracerImploperator<< (T const &entry)
 output operator We return a TracerImpl instead of ourself to make subsequent access faster. More...
 
TracerImploperator<< (std::ostream &(*entry)(std::ostream &))
 
 operator std::ostream & ()
 Allow Tracer object to be passed to something expecting a std::ostream. More...
 
void flush ()
 
void flush_all_channels ()
 flush tracer buffer and flush buffers of all sub-channels ie: Fatal, Error, Warning, Info, Debug, Trace More...
 
bool visible ()
 
bool visible (int priority)
 
std::string const & channel ()
 
TracerImploperator() (int priority)
 
void set_local_print_channel_name (bool const setting)
 Set whether we're printing the channel name. More...
 
bool get_local_print_channel_name ()
 Get whether we're printing the channel name. More...
 
std::streamsize width ()
 
std::streamsize width (std::streamsize wide)
 
std::streamsize precision ()
 
std::streamsize precision (std::streamsize prec)
 
std::ios_base::fmtflags flags ()
 
std::ios_base::fmtflags flags (std::ios_base::fmtflags fmtfl)
 

Static Public Member Functions

static void set_ios_hook (otstreamOP tr, std::string const &monitoring_channels_list, bool raw=true)
 TODO: See if we can kill any usage of this, except for the esoteric. More...
 
static std::string const & get_all_channels_string ()
 
static bool super_mute ()
 global super mute flag that allow to mute all io no matter what. More...
 
static void super_mute (bool f)
 

Public Attributes

TracerProxy Fatal
 channels with predefined priority levels. More...
 
TracerProxy Error
 
TracerProxy Warning
 
TracerProxy Info
 
TracerProxy Debug
 
TracerProxy Trace
 

Static Public Attributes

static utility::CSI::CSI_Enum Reset
 
static utility::CSI::CSI_Enum Bold
 
static utility::CSI::CSI_Enum Underline
 
static utility::CSI::CSI_Enum Black
 
static utility::CSI::CSI_Enum Red
 
static utility::CSI::CSI_Enum Green
 
static utility::CSI::CSI_Enum Yellow
 
static utility::CSI::CSI_Enum Blue
 
static utility::CSI::CSI_Enum Magenta
 
static utility::CSI::CSI_Enum Cyan
 
static utility::CSI::CSI_Enum White
 
static utility::CSI::CSI_Enum bgBlack
 
static utility::CSI::CSI_Enum bgRed
 
static utility::CSI::CSI_Enum bgGreen
 
static utility::CSI::CSI_Enum bgYellow
 
static utility::CSI::CSI_Enum bgBlue
 
static utility::CSI::CSI_Enum bgMagenta
 
static utility::CSI::CSI_Enum bgCyan
 
static utility::CSI::CSI_Enum bgWhite
 

Protected Member Functions

TracerImpltracer_impl ()
 The function which handles the construct-on-first use Not virtual for speed in the usual (non-creation) case. More...
 
virtual std::unique_ptr
< TracerImpl
create_impl ()
 

Private Attributes

std::string channel_
 
utility::CSI::CSI_Enum channel_color_
 
utility::CSI::CSI_Enum channel_name_color_
 
TracerPriority priority_
 
bool muted_by_default_
 

Detailed Description

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 'basic.scoring.myfile'.

Intended usage is as a global-scope static object. If you need a heap/stack allocated object, use the TracerImpl class directly.

The funky indirection to TracerImpl here is so that the heavy-weight TracerImpl object is only constructed on first use, and isn't static or thread_local

Constructor & Destructor Documentation

basic::Tracer::Tracer ( std::string const &  channel = "",
TracerPriority  priority = t_info,
bool  muted_by_default = false 
)

Create Tracer object with given channel and priority.

basic::Tracer::Tracer ( std::string const &  channel,
utility::CSI::CSI_Enum const &  channel_color,
utility::CSI::CSI_Enum 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", utility::CSI::Blue);

basic::Tracer::~Tracer ( )
virtualdefault

Ideally, we'd clean ourselves up from the tracer_impl_map, but that's complicated by it being a) thread-dependent, and b) subject to static initialization order fiasco (static destruction order fiasco) issues. Regardless, the associated TracerImpl will be flushed when the static tracer_impl_map gets destroyed. The one tricky bit is that the TracerImpl for non-static tracers stick around, and may accidentally be re-used if we re-use the same pointer ... so avoid non-static Tracer objects: use a TracerImpl directly instead.

basic::Tracer::Tracer ( Tracer const &  )
delete

Member Function Documentation

std::string const& basic::Tracer::channel ( )
inline
std::unique_ptr< TracerImpl > basic::Tracer::create_impl ( )
protectedvirtual
std::ios_base::fmtflags basic::Tracer::flags ( )
inline

References tracer_impl().

std::ios_base::fmtflags basic::Tracer::flags ( std::ios_base::fmtflags  fmtfl)
inline

References tracer_impl().

void basic::Tracer::flush ( )
inline
void basic::Tracer::flush_all_channels ( )
inline

flush tracer buffer and flush buffers of all sub-channels ie: Fatal, Error, Warning, Info, Debug, Trace

References basic::TracerImpl::flush_all_channels(), and tracer_impl().

Referenced by main().

static std::string const& basic::Tracer::get_all_channels_string ( )
inlinestatic
bool basic::Tracer::get_local_print_channel_name ( )
inline

Get whether we're printing the channel name.

This looks at the local setting, but does not check the global setting.

Note
In practice, if the local setting is true then the global setting is used. If the local setting is false, it overrides the global setting.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org)

References basic::TracerImpl::get_local_print_channel_name(), and tracer_impl().

basic::Tracer::operator std::ostream & ( )
inline

Allow Tracer object to be passed to something expecting a std::ostream.

References tracer_impl().

TracerImpl& basic::Tracer::operator() ( int  priority)
inline

References tracer_impl().

template<typename T >
TracerImpl& basic::Tracer::operator<< ( T const &  entry)
inline

output operator We return a TracerImpl instead of ourself to make subsequent access faster.

References tracer_impl().

TracerImpl& basic::Tracer::operator<< ( std::ostream &(*)(std::ostream &)  entry)
inline

References tracer_impl().

Tracer& basic::Tracer::operator= ( Tracer const &  )
delete
std::streamsize basic::Tracer::precision ( )
inline

References tracer_impl().

std::streamsize basic::Tracer::precision ( std::streamsize  prec)
inline

References tracer_impl().

static void basic::Tracer::set_ios_hook ( otstreamOP  tr,
std::string const &  monitoring_channels_list,
bool  raw = true 
)
inlinestatic

TODO: See if we can kill any usage of this, except for the esoteric.

References basic::options::OptionKeys::out::file::raw, and basic::TracerImpl::set_ios_hook().

void basic::Tracer::set_local_print_channel_name ( bool const  setting)
inline

Set whether we're printing the channel name.

This overrides the local setting, but does not alter the global setting.

Note
In practice, if the local setting is true then the global setting is used. If the local setting is false, it overrides the global setting.
Author
Vikram K. Mulligan (vmull.nosp@m.igan.nosp@m.@flat.nosp@m.iron.nosp@m.insti.nosp@m.tute.nosp@m..org)

References basic::TracerImpl::set_local_print_channel_name(), and tracer_impl().

static bool basic::Tracer::super_mute ( )
inlinestatic

global super mute flag that allow to mute all io no matter what.

References basic::TracerImpl::super_mute().

static void basic::Tracer::super_mute ( bool  f)
inlinestatic
TracerImpl & basic::Tracer::tracer_impl ( )
protected

The function which handles the construct-on-first use Not virtual for speed in the usual (non-creation) case.

References create_impl(), and THREAD_LOCAL.

Referenced by channel(), flags(), flush(), flush_all_channels(), get_local_print_channel_name(), operator std::ostream &(), operator()(), operator<<(), precision(), set_local_print_channel_name(), basic::Tracer::TracerProxy::tracer_proxy_impl(), visible(), and width().

bool basic::Tracer::visible ( )
inline

References tracer_impl(), and basic::TracerImpl::visible().

Referenced by main().

bool basic::Tracer::visible ( int  priority)
inline
std::streamsize basic::Tracer::width ( )
inline

References tracer_impl().

std::streamsize basic::Tracer::width ( std::streamsize  wide)
inline

References tracer_impl().

Member Data Documentation

utility::CSI::CSI_Enum basic::Tracer::bgBlack
static
utility::CSI::CSI_Enum basic::Tracer::bgBlue
static
utility::CSI::CSI_Enum basic::Tracer::bgCyan
static
utility::CSI::CSI_Enum basic::Tracer::bgGreen
static
utility::CSI::CSI_Enum basic::Tracer::bgMagenta
static
utility::CSI::CSI_Enum basic::Tracer::bgRed
static
utility::CSI::CSI_Enum basic::Tracer::bgWhite
static
utility::CSI::CSI_Enum basic::Tracer::bgYellow
static
utility::CSI::CSI_Enum basic::Tracer::Black
static
utility::CSI::CSI_Enum basic::Tracer::Blue
static
utility::CSI::CSI_Enum basic::Tracer::Bold
static
std::string basic::Tracer::channel_
private

Referenced by create_impl().

utility::CSI::CSI_Enum basic::Tracer::channel_color_
private

Referenced by create_impl().

utility::CSI::CSI_Enum basic::Tracer::channel_name_color_
private

Referenced by create_impl().

utility::CSI::CSI_Enum basic::Tracer::Cyan
static
TracerProxy basic::Tracer::Debug
TracerProxy basic::Tracer::Error
TracerProxy basic::Tracer::Fatal
utility::CSI::CSI_Enum basic::Tracer::Green
static
TracerProxy basic::Tracer::Info

Referenced by main(), and run().

utility::CSI::CSI_Enum basic::Tracer::Magenta
static
bool basic::Tracer::muted_by_default_
private

Referenced by create_impl().

TracerPriority basic::Tracer::priority_
private

Referenced by create_impl().

utility::CSI::CSI_Enum basic::Tracer::Red
static
utility::CSI::CSI_Enum basic::Tracer::Reset
static
TracerProxy basic::Tracer::Trace
utility::CSI::CSI_Enum basic::Tracer::Underline
static
TracerProxy basic::Tracer::Warning
utility::CSI::CSI_Enum basic::Tracer::White
static
utility::CSI::CSI_Enum basic::Tracer::Yellow
static

The documentation for this class was generated from the following files: