9#ifndef Sawyer_Message_H
10#define Sawyer_Message_H
12#include <Sawyer/Map.h>
13#include <Sawyer/Optional.h>
14#include <Sawyer/Sawyer.h>
15#include <Sawyer/SharedPointer.h>
16#include <Sawyer/Synchronization.h>
18#include <boost/config.hpp>
19#include <boost/logic/tribool.hpp>
20#include <boost/regex.hpp>
288#if defined(DEBUG) || defined(TRACE) || defined(WHERE) || defined(MARCH) || \
289 defined(INFO) || defined(WARN) || defined(ERROR) || defined(FATAL)
291# pragma message("Undefining common words from the global namespace: DEBUG, TRACE, WHERE, MARCH, INFO, WARN, ERROR, FATAL")
293# warning "Undefining common words from the global namespace: DEBUG, TRACE, WHERE, MARCH, INFO, WARN, ERROR, FATAL"
363SAWYER_EXPORT
double now();
364SAWYER_EXPORT std::string
escape(
const std::string&);
377#include <Sawyer/WarningsOff.h>
379#include <Sawyer/WarningsRestore.h>
427#include <Sawyer/WarningsOff.h>
436#include <Sawyer/WarningsRestore.h>
438 MesgProps(): isBuffered(boost::indeterminate), useColor(boost::indeterminate) {}
514 static unsigned nextId_;
516#include <Sawyer/WarningsOff.h>
518#include <Sawyer/WarningsRestore.h>
526 : id_(nextId_++), isComplete_(false), isCanceled_(false) {}
530 : id_(nextId_++), isComplete_(false), isCanceled_(false) {
537 : id_(nextId_++), isComplete_(false), isCanceled_(false), props_(props) {}
540 explicit Mesg(
const std::string &mesg)
541 : id_(nextId_++), text_(mesg), isComplete_(true), isCanceled_(false) {}
546 : id_(nextId_++), text_(mesg), isComplete_(true), isCanceled_(false) {
553 : id_(nextId_++), text_(mesg), isComplete_(true), isCanceled_(false), props_(props) {}
556 unsigned id()
const {
return id_; }
559 const std::string&
text()
const {
return text_; }
570 bool isEmpty()
const {
return text_.empty(); }
611 mutable SAWYER_THREAD_TRAITS::RecursiveMutex
mutex_;
670 typedef std::list<DestinationPtr> Destinations;
671#include <Sawyer/WarningsOff.h>
672 Destinations destinations_;
673#include <Sawyer/WarningsRestore.h>
758 : nSkip_(nskip), rate_(rate), limit_(limit), nPosted_(0) {}
820 double initialDelay_;
822 double prevMessageTime_;
823 double lastBakeTime_;
830 : initialDelay_(0.0), minInterval_(minInterval), prevMessageTime_(0.0), lastBakeTime_(0.0) {}
887 memset(enabled_, dflt?0xff:0,
sizeof enabled_);
936 mutable SAWYER_THREAD_TRAITS::RecursiveMutex mutex_;
942 SAWYER_THREAD_TRAITS::RecursiveMutex& mutex()
const {
return mutex_; }
967 static const int TTY_GANG = -1;
968 static const int NO_GANG_ID = -2;
969 static SAWYER_THREAD_TRAITS::Mutex classMutex_;
978 static GangPtr createNS(
int id);
987#include <Sawyer/WarningsOff.h>
996 mutable SAWYER_THREAD_TRAITS::RecursiveMutex mutex_;
999 bool showProgramName_;
1002 bool showElapsedTime_;
1003 When showFacilityName_;
1004 bool showImportance_;
1005 void initFromSystem();
1006#include <Sawyer/WarningsRestore.h>
1012 : showProgramName_(true), showThreadId_(true), showElapsedTime_(true), showFacilityName_(SOMETIMES),
1013 showImportance_(true) {
1015 colorSet_ = ColorSet::fullColor();
1160#include <Sawyer/WarningsOff.h>
1163#include <Sawyer/WarningsRestore.h>
1166 bool partialMessagesAllowed_;
1171 gang_ = Gang::instance();
1172 prefix_ = prefix ? prefix : Prefix::instance();
1325 std::ostream &stream_;
1338#ifndef BOOST_WINDOWS
1377 SProxy(): stream_(NULL) {}
1383 Stream& operator*() {
return *stream_; }
1384 Stream* operator->() {
return stream_; }
1385 Stream* get()
const {
return stream_; }
1386 operator bool()
const;
1396class SAWYER_EXPORT
Stream:
public std::ostream {
1397 friend class StreamBuf;
1398 mutable SAWYER_THREAD_TRAITS::Mutex mutex_;
1400 StreamBuf *streambuf_;
1450 void incrementRefCount();
1451 size_t decrementRefCount();
1506 operator void*()
const {
1507 return enabled() ?
const_cast<Stream*
>(
this) : NULL;
1509#if __cplusplus >= 201103L
1510 explicit operator bool()
const {
1515 operator bool()
const {
1525 #define SAWYER_MESG(message_stream) (message_stream) && (message_stream)
1526 #define SAWYER_MSG(message_stream) (message_stream) && (message_stream)
1528 #define SAWYER_MESG_FIRST(...) Sawyer::Message::firstEnabled(__VA_ARGS__) && Sawyer::Message::firstEnabled(__VA_ARGS__)
1529 #define SAWYER_MESG_OR(s1, s2) SAWYER_MESG_FIRST(s1, s2)
1530 #define SAWYER_MSG_OR(s1, s2) SAWYER_MESG_FIRST(s1, s2)
1607 static const unsigned CONSTRUCTED_MAGIC = 0x73617779;
1608 unsigned constructed_;
1609 mutable SAWYER_THREAD_TRAITS::Mutex mutex_;
1610#include <Sawyer/WarningsOff.h>
1611 std::string name_, comment_;
1612 std::vector<SProxy> streams_;
1613#include <Sawyer/WarningsRestore.h>
1633 Facility(
const std::string &name,
const DestinationPtr &destination): constructed_(CONSTRUCTED_MAGIC), name_(name) {
1634 initStreams(destination);
1720 static std::vector<std::string> parseName(
const std::string&);
1741 mutable SAWYER_THREAD_TRAITS::Mutex mutex_;
1742#include <Sawyer/WarningsOff.h>
1745 bool impsetInitialized_;
1746#include <Sawyer/WarningsRestore.h>
1754 impset_.insert(
WARN);
1755 impset_.insert(
ERROR);
1756 impset_.insert(
FATAL);
1757 impsetInitialized_ =
false;
1942 struct ControlTerm {
1943 ControlTerm(
const boost::regex &facilityNamePattern,
bool enable)
1944 : facilityNamePattern(facilityNamePattern), lo(
DEBUG), hi(
DEBUG), enable(enable) {}
1945 std::string toString()
const;
1946 boost::regex facilityNamePattern;
1951 Facilities& insertNS(Facility&, std::string);
1952 Facilities& enableNS(Importance,
bool);
1955 struct ControlError {
1956 ControlError(
const std::string &mesg,
const char *position): mesg(mesg), inputPosition(position) {}
1958 const char *inputPosition;
1962 static boost::regex parseFacilityNamePattern(
const char* &input);
1963 static std::string parseEnablement(
const char* &input);
1964 static std::string parseRelation(
const char* &input);
1965 static std::string parseImportanceName(
const char* &input);
1966 static Importance importanceFromString(
const std::string&);
1967 static std::list<ControlTerm> parseImportanceList(
const boost::regex &facilityNamePattern,
const char* &input,
bool isGlobal);
1970 void eraseDestroyedNS();
1973 std::vector<Facility*> matchingFacilitiesNS(
const boost::regex &namePattern)
const;
1984SAWYER_EXPORT
extern Facility
mlog;
2033 : facilities_(facilities) {
Container associating values with keys.
Colors to use for each message importance.
ColorSpec & operator[](Importance imp)
Colors for a message.
static ColorSet blackAndWhite()
Returns a color set that uses only default colors.
static ColorSet fullColor()
Returns a color set that uses various foreground colors for the different message importance levels.
const ColorSpec & operator[](Importance imp) const
Colors for a message.
Base class for all types of message destinations.
MesgProps & defaultPropertiesNS()
Default values for message properties.
virtual void bakeDestinations(const MesgProps &, BakedDestinations &baked)
Bakes message properties according to the plumbing lattice.
virtual void post(const Mesg &, const MesgProps &bakedProperties)=0
Causes a message to be emitted.
MesgProps dflts_
Default properties merged into each incoming message.
const MesgProps & overridePropertiesNS() const
Overrides message properties.
MesgProps mergePropertiesNS(const MesgProps &props)
Merge properties of this lattice node into the specified properties.
Sawyer::SynchronizationTraits< Sawyer::SingleThreadedTag >::RecursiveMutex mutex_
Mutex protecting data members here and in subclasses.
MesgProps & overridePropertiesNS()
Overrides message properties.
MesgProps overrides_
Override properties applied to incoming message.
const MesgProps & defaultPropertiesNS() const
Default values for message properties.
Saves and restores facilities.
~FacilitiesGuard()
Restores previously saved facility settings.
FacilitiesGuard(Facilities &facilities)
Saves and restores specified message facilities.
FacilitiesGuard()
Saves and restores the global message facilities.
Collection of facilities.
Facilities & disable()
Enable/disable all facilities.
Facilities & enable(const std::string &switch_name, bool b=true)
Enable/disable a facility by name.
Facilities & enable(bool b=true)
Enable/disable all facilities.
Facilities & impset(Importance, bool enabled)
Add or remove a default importance level.
void print(std::ostream &) const
Print the list of facilities and their states.
std::string control(const std::string &s)
Parse a single command-line switch and enable/disable the indicated streams.
ImportanceSet impset() const
Return the set of default-enabled message importances.
Facility & facility(const std::string &name) const
Return an existing facility by name.
Facilities & enable(Importance, bool b=true)
Enable/disable specific importance level across all facilities.
Facilities(const Facilities &)
Copy constructor.
Facilities & insert(Facility &facility, const std::string &name="")
Register a facility so it can be controlled as part of a collection of facilities.
std::set< Importance > ImportanceSet
A set of importance levels.
void shutdown()
Reset facilities to initial state.
Facilities & reenableFrom(const Facilities &other)
Readjust all member facilities.
Facilities & disable(Importance imp)
Enable/disable specific importance level across all facilities.
std::vector< std::string > facilityNames() const
Return names for all known facilities.
Facilities & erase(Facility &facility)
Remove all occurrences of the facility.
Facilities & reenable()
Readjust all member facilities.
Facilities & insertAndAdjust(Facility &facility, std::string name="")
Register a facility so it can be controlled as part of a collection of facilities.
Facilities & operator=(const Facilities &)
Assignment operator.
Facilities & disable(const std::string &switch_name)
Enable/disable a facility by name.
std::string configuration() const
Returns a configuration string.
Facilities()
Constructs an empty container of Facility objects.
Facilities & erase(const std::string &name)
Remove a facility by name.
Facility & initialize(const std::string &name)
Initializes this facility with default destinations.
Stream & operator[](Importance imp)
Returns a stream for the specified importance level.
Stream & get(Importance imp)
Returns a stream for the specified importance level.
std::string name() const
Return the name of the facility.
bool isConstructed() const
Returns true if called on an object that has been constructed.
Facility & initStreams(const DestinationPtr &)
Cause all streams to use the specified destination.
Facility(const Facility &other)
Construct a new facility from an existing facility.
Facility()
Construct an empty facility.
Facility & comment(const std::string &)
Property: Comment associated with facility.
Facility & renameStreams(const std::string &name="")
Renames all the facility streams.
std::string comment() const
Property: Comment associated with facility.
Facility & operator=(const Facility &src)
Assignment operator.
Facility & initialize(const std::string &name, const DestinationPtr &destination)
Initialize all streams with specified destination.
static bool isValidName(const std::string &)
Tests whether a name is valie.
Send free-format messages to a Unix file descriptor.
virtual void post(const Mesg &, const MesgProps &)
Causes a message to be emitted.
FdSink(int fd, const PrefixPtr &prefix)
Constructor for derived classes.
static FdSinkPtr instance(int fd, const PrefixPtr &prefix=PrefixPtr())
Allocating constructor.
Send free-format messages to a C FILE pointer.
FileSink(FILE *f, const PrefixPtr &prefix)
Constructor for derived classes.
static FileSinkPtr instance(FILE *f, const PrefixPtr &prefix=PrefixPtr())
Allocating constructor.
virtual void post(const Mesg &, const MesgProps &)
Causes a message to be emitted.
Base class for internal nodes that filter messages.
Filter()
Constructor for derived classes.
virtual void bakeDestinations(const MesgProps &, BakedDestinations &)
Bakes message properties according to the plumbing lattice.
virtual void forwarded(const MesgProps &)=0
Called once by bakeDestinations if shouldForward() returned true.
virtual bool shouldForward(const MesgProps &)=0
Predicate determines when a message should be forwarded onward.
static GangPtr instanceForTty()
Returns the gang for streams that are emitting to a tty.
static void shutdownNS()
Reset to initial state to free memory.
static GangPtr instanceForId(int id)
The gang for the specified ID, creating a new one if necessary.
static GangPtr instance()
New non-shared gang with NO_GANG_ID.
void clear()
Reset to initial state.
void emitted(const Mesg &, const MesgProps &)
Make specified message the high water mark.
unsigned id() const
Exception unless isValid().
bool isValid() const
Returns true if high water is defined.
size_t ntext() const
Zero if !isValid().
Filters messages based on importance level.
static ImportanceFilterPtr instance(bool dflt)
Allocating constructor.
virtual bool shouldForward(const MesgProps &)
Predicate determines when a message should be forwarded onward.
ImportanceFilterPtr disable(Importance)
Disable an importance level.
ImportanceFilter(bool dflt)
Constructor for derived classes.
virtual void forwarded(const MesgProps &)
Called once by bakeDestinations if shouldForward() returned true.
bool enabled(Importance imp) const
Property: the enabled/disabled state for a message importance level.
ImportanceFilterPtr enable(Importance)
Enable an importance level.
ImportanceFilterPtr enabled(Importance imp, bool b)
Property: the enabled/disabled state for a message importance level.
void post(const BakedDestinations &) const
Send a message to its final destinations.
bool isCanceled() const
Returns true if the message has entered the canceled state.
bool isComplete() const
Returns true if the message has entered the completed state.
bool hasText() const
Returns true if the message has text other than white space.
unsigned id() const
Return unique message ID.
Mesg(const MesgProps &props, const std::string &mesg)
Creates a new, completed message with the specified text.
MesgProps & properties()
Returns a reference to message properties.
Mesg()
Creates a new, partial message that is empty.
void insert(char)
Append additional text to the end of the message.
bool isEmpty() const
Returns true if the message has no text.
Mesg(const std::string &facilityName, Importance imp)
Creates a new, partial message that is empty.
Mesg(const std::string &mesg)
Creates a new, completed message with the specified text.
Mesg(const MesgProps &props)
Creates a new, partial message that is empty.
Mesg(const std::string &facilityName, Importance imp, const std::string &mesg)
Creates a new, completed message with the specified text.
void cancel()
Cause the message to enter the canceled state.
const std::string & text() const
Return the message text.
void insert(const std::string &)
Append additional text to the end of the message.
void complete()
Cause the message to enter the completed state.
const MesgProps & properties() const
Returns a reference to message properties.
Sends incoming messages to multiple destinations.
static MultiplexerPtr instance()
Allocating constructor.
MultiplexerPtr to(const DestinationPtr &, const DestinationPtr &, const DestinationPtr &)
Add a child nodes to this node of the lattice and returns this node.
Multiplexer()
Constructor for derived classes.
MultiplexerPtr to(const DestinationPtr &)
Add a child nodes to this node of the lattice and returns this node.
MultiplexerPtr removeDestination(const DestinationPtr &)
Removes the specified child from this node of the lattice.
MultiplexerPtr addDestination(const DestinationPtr &)
Adds a child node to this node of the lattice.
virtual void bakeDestinations(const MesgProps &, BakedDestinations &)
Bakes message properties according to the plumbing lattice.
MultiplexerPtr to(const DestinationPtr &, const DestinationPtr &)
Add a child nodes to this node of the lattice and returns this node.
virtual void post(const Mesg &, const MesgProps &)
Causes a message to be emitted.
MultiplexerPtr to(const DestinationPtr &, const DestinationPtr &, const DestinationPtr &, const DestinationPtr &)
Add a child nodes to this node of the lattice and returns this node.
Information printed at the beginning of each free-format message.
void setProgramName()
Reset the program name from operating system information.
const Optional< std::string > & programName() const
Property: program name.
bool showProgramName() const
Property: whether to show the program name in the message prefix area.
PrefixPtr showElapsedTime(bool b)
Property: whether to show time deltas.
PrefixPtr startTime(double t)
Property: start time when emitting time deltas.
When showFacilityName() const
Property: whether to show the facilityName property.
static PrefixPtr instance()
Allocating constructor.
void setStartTime()
Reset the start time from operating system information.
PrefixPtr showFacilityName(When w)
Property: whether to show the facilityName property.
const ColorSet & colorSet() const
Property: colors to use for the prefix if coloring is enabled.
bool showThreadId() const
Property: whether to show the thread ID in the message prefix area.
ColorSet & colorSet()
Property: colors to use for the prefix if coloring is enabled.
When
When to show something.
PrefixPtr programName(const std::string &s)
Property: program name.
PrefixPtr showImportance(bool b)
Property: whether to show the importance property.
PrefixPtr showThreadId(bool b)
Property: whether to show the thread ID in the message prefix area.
Prefix()
Constructor for derived classes.
bool showElapsedTime() const
Property: whether to show time deltas.
const Optional< double > startTime() const
Property: start time when emitting time deltas.
bool showImportance() const
Property: whether to show the importance property.
PrefixPtr showProgramName(bool b)
Property: whether to show the program name in the message prefix area.
virtual std::string toString(const Mesg &, const MesgProps &) const
Return a prefix string.
static PrefixPtr silentInstance()
Construct a prefix that is silent.
Filters messages based on how many messages have been seen.
SequenceFilterPtr limit(size_t n)
Property: total number of messages forwarded.
size_t rate() const
Property: rate of messages to emit after initial messages are skipped.
size_t nPosted() const
Number of messages processed.
static SequenceFilterPtr instance(size_t nskip, size_t rate, size_t limit)
Construct an instance.
size_t limit() const
Property: total number of messages forwarded.
size_t nSkip() const
Property: number of initial messages to skip.
SequenceFilterPtr rate(size_t n)
Property: rate of messages to emit after initial messages are skipped.
SequenceFilterPtr nSkip(size_t n)
Property: number of initial messages to skip.
SequenceFilter(size_t nskip, size_t rate, size_t limit)
Constructor for derived classes.
virtual void forwarded(const MesgProps &)
Called once by bakeDestinations if shouldForward() returned true.
virtual bool shouldForward(const MesgProps &)
Predicate determines when a message should be forwarded onward.
Send free-format messages to a C++ I/O stream.
virtual void post(const Mesg &, const MesgProps &)
Causes a message to be emitted.
static StreamSinkPtr instance(std::ostream &stream, const PrefixPtr &prefix=PrefixPtr())
Allocating constructor.
StreamSink(std::ostream &stream, const PrefixPtr &prefix)
Constructor for derived classes.
Converts text to messages.
Stream & operator=(const std::ostream &other_)
Assignment with dynamic cast.
Stream(const Stream &other)
Construct a new stream from an existing stream.
void cancelationString(const std::string &s, bool asDefault=true)
Set message or stream property.
void interruptionString(const std::string &s, bool asDefault=true)
Set message or stream property.
Stream & destination(const DestinationPtr &d)
Property: message destination.
bool operator!() const
Returns false if this stream is enabled.
void facilityName(const std::string &s, bool asDefault=true)
Set message or stream property.
void disable()
Enable or disable a stream.
Stream & operator=(const Stream &other)
Initialize this stream from another stream.
void completionString(const std::string &s, bool asDefault=true)
Set message or stream property.
bool enabled() const
Returns true if a stream is enabled.
void initFromNS(const Stream &other)
Initiaize this stream from other.
Stream(const MesgProps &props, const DestinationPtr &destination)
Construct a stream and initialize its properties as specified.
Stream(const std::ostream &other_)
Copy constructor with dynamic cast.
SProxy dup() const
Used for partial messages when std::move is missing.
MesgProps properties() const
Return the default properties for this stream.
Stream(const std::string facilityName, Importance imp, const DestinationPtr &destination)
Construct a stream and initialize its name and importance properties.
DestinationPtr destination() const
Property: message destination.
void enable(bool b=true)
Enable or disable a stream.
Sends messages to the syslog daemon.
static SyslogSinkPtr instance(const char *ident, int option, int facility)
Allocating constructor.
virtual void post(const Mesg &, const MesgProps &)
Causes a message to be emitted.
SyslogSink(const char *ident, int option, int facility)
Constructor for derived classes.
Filters messages based on time.
static TimeFilterPtr instance(double minInterval)
Allocating constructor.
virtual void forwarded(const MesgProps &)
Called once by bakeDestinations if shouldForward() returned true.
double minInterval() const
Property: minimum time between messages.
double initialDelay() const
Property: delay before the next message.
TimeFilter(double minInterval)
Constructor for derived classes.
TimeFilterPtr minInterval(double d)
Property: minimum time between messages.
virtual bool shouldForward(const MesgProps &)
Predicate determines when a message should be forwarded onward.
TimeFilterPtr initialDelay(double d)
Property: delay before the next message.
size_t nPosted() const
Number of messages processed.
Holds a value or nothing.
Creates SharedPointer from this.
Base class for reference counted objects.
Reference-counting intrusive smart pointer.
SharedPointer< class Multiplexer > MultiplexerPtr
Smart pointer.
SharedPointer< class Gang > GangPtr
Smart pointer.
Facilities mfacilities
Library-provided facility group.
DestinationPtr merr
Library-provided message destination.
std::string stringifyColor(AnsiColor)
Convert an AnsiColor enum to a string.
SharedPointer< class UnformattedSink > UnformattedSinkPtr
Smart pointer.
Facility mlog
Facility used by Sawyer components.
SharedPointer< class Filter > FilterPtr
Smart pointer.
std::vector< BakedDestination > BakedDestinations
Baked properties for multiple destinations.
bool isTerminal(int fd)
True if fd is a tty.
SharedPointer< class SequenceFilter > SequenceFilterPtr
Smart pointer.
SharedPointer< class Prefix > PrefixPtr
Smart pointer.
SharedPointer< class ImportanceFilter > ImportanceFilterPtr
Smart pointer.
SProxy assertionStream
The stream to be used for assertions.
SharedPointer< class FdSink > FdSinkPtr
Smart pointer.
SharedPointer< class Destination > DestinationPtr
Smart pointer.
void shutdown()
Reset global variables to initial states.
bool initializeLibrary()
Explicitly initialize the library.
SharedPointer< class SyslogSink > SyslogSinkPtr
Smart pointer.
std::ostream & operator<<(std::ostream &o, const MesgProps &props)
Print the values for all message properties.
std::pair< DestinationPtr, MesgProps > BakedDestination
Baked properties for a destination.
Importance
Level of importance for a message.
@ N_IMPORTANCE
Number of distinct importance levels.
@ WARN
Warning messages that indicate an unusual situation from which the program was able to fully recover.
@ MARCH
Progress reports and other similar rapidly updating partial messages.
@ ERROR
Error messages that indicate an abnormal situation from which the program was able to at least partia...
@ TRACE
Detailed tracing information useful to end-users that are trying to understand program internals.
@ INFO
Informative messages.
@ FATAL
Messages that indicate an abnormal situation from which the program was unable to recover.
@ DEBUG
Messages intended to be useful primarily to the author of the code.
@ WHERE
Granular tracing information useful to end-users that are trying to understand program internals.
SharedPointer< class StreamSink > StreamSinkPtr
Smart pointer.
SharedPointer< class TimeFilter > TimeFilterPtr
Smart pointer.
SharedPointer< class FileSink > FileSinkPtr
Smart pointer.
double now()
Current system time in seconds.
AnsiColor
Colors used by sinks that write to terminals.
@ COLOR_CYAN
ANSI "cyan" color.
@ COLOR_RED
ANSI "red" color.
@ COLOR_YELLOW
ANSI "yellow" color.
@ COLOR_WHITE
ANSI "white" color.
@ COLOR_MAGENTA
ANSI "magenta" color.
@ COLOR_BLUE
ANSI "blue" color.
@ COLOR_DEFAULT
ANSI default color.
@ COLOR_GREEN
ANSI "green" color.
@ COLOR_BLACK
ANSI "black" color.
std::string escape(const std::string &)
Convert a string to its C representation.
std::string stringifyImportance(Importance)
Convert an Importance enum to a string.
ANSI Color specification for text written to a terminal.
AnsiColor background
Background color, or COLOR_DEFAULT.
ColorSpec(AnsiColor fg)
Constructs an object that specifies only a foreground color.
ColorSpec(AnsiColor fg, AnsiColor bg, bool bold)
Constructs an object with fully-specified colors.
bool isDefault() const
Returns true if this object is in its default-constructed state.
boost::tribool bold
Use ANSI "bold" attribute?
AnsiColor foreground
Foreground color, or COLOR_DEFAULT.
ColorSpec()
Constructs an object with default foreground and background colors.
Optional< std::string > cancelationStr
String to append to a partial message when it is destroyed.
boost::tribool useColor
Whether to use ANSI escape sequences to colorize output.
void print(std::ostream &) const
Print the values for all properties.
MesgProps merge(const MesgProps &) const
Merge the specified properties into this object and return new properties.
Optional< std::string > interruptionStr
String to append when a partial message is interrupted.
Optional< Importance > importance
The message importance level.
Optional< std::string > completionStr
String to append to the end of each complete message.
Optional< std::string > facilityName
The name of the logging facility that produced this message.
Optional< std::string > lineTermination
Line termination for completion, interruption, and cancelation.
boost::tribool isBuffered
Whether the output buffered and emitted on a per-message basis.