mirror of
				https://github.com/Zygo/bees.git
				synced 2025-11-03 19:50:34 +01:00 
			
		
		
		
	chatter: use static function to control timestamping behavior
Use a static function instead of embedding side-effects in the constructor
of an unrelated class.
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
(cherry picked from commit 85106bd9a9)
			
			
This commit is contained in:
		@@ -45,6 +45,8 @@ namespace crucible {
 | 
				
			|||||||
		template <class T> Chatter &operator<<(const T& arg);
 | 
							template <class T> Chatter &operator<<(const T& arg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		~Chatter();
 | 
							~Chatter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							static void enable_timestamp(bool prefix_timestamp);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template <class Argument>
 | 
						template <class Argument>
 | 
				
			||||||
@@ -86,11 +88,6 @@ namespace crucible {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class ChatterTimestamp {
 | 
					 | 
				
			||||||
	public:
 | 
					 | 
				
			||||||
		ChatterTimestamp(int);
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	class ChatterBox {
 | 
						class ChatterBox {
 | 
				
			||||||
		string m_file;
 | 
							string m_file;
 | 
				
			||||||
		int m_line;
 | 
							int m_line;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ namespace crucible {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	static shared_ptr<set<string>> chatter_names;
 | 
						static shared_ptr<set<string>> chatter_names;
 | 
				
			||||||
	static const char *SPACETAB = " \t";
 | 
						static const char *SPACETAB = " \t";
 | 
				
			||||||
	static int chatter_prefix_timestamp = 1;
 | 
						static bool add_prefix_timestamp = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static
 | 
						static
 | 
				
			||||||
	void
 | 
						void
 | 
				
			||||||
@@ -49,11 +49,17 @@ namespace crucible {
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void
 | 
				
			||||||
 | 
						Chatter::enable_timestamp(bool prefix_timestamp)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							add_prefix_timestamp = prefix_timestamp;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Chatter::~Chatter()
 | 
						Chatter::~Chatter()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		ostringstream header_stream;
 | 
							ostringstream header_stream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (chatter_prefix_timestamp) {
 | 
							if (add_prefix_timestamp) {
 | 
				
			||||||
			time_t ltime;
 | 
								time_t ltime;
 | 
				
			||||||
			DIE_IF_MINUS_ONE(time(<ime));
 | 
								DIE_IF_MINUS_ONE(time(<ime));
 | 
				
			||||||
			struct tm ltm;
 | 
								struct tm ltm;
 | 
				
			||||||
@@ -97,11 +103,6 @@ namespace crucible {
 | 
				
			|||||||
		c.m_oss.str("");
 | 
							c.m_oss.str("");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ChatterTimestamp::ChatterTimestamp(int prefix_timestamp)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		chatter_prefix_timestamp = prefix_timestamp;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	set<ChatterBox*> ChatterBox::s_boxes;
 | 
						set<ChatterBox*> ChatterBox::s_boxes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	set<ChatterBox*>& ChatterBox::all_boxes()
 | 
						set<ChatterBox*>& ChatterBox::all_boxes()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user