mirror of
				https://github.com/eclipse/upm.git
				synced 2025-10-31 23:24:20 +03:00 
			
		
		
		
	Upm logger
Signed-off-by: Mihai Stefanescu <mihai.t.gh.stefanescu@gmail.com>
This commit is contained in:
		 Mihai Stefanescu
					Mihai Stefanescu
				
			
				
					committed by
					
						 Stefan Andritoiu
						Stefan Andritoiu
					
				
			
			
				
	
			
			
			 Stefan Andritoiu
						Stefan Andritoiu
					
				
			
						parent
						
							dc45cd7859
						
					
				
				
					commit
					c23d076a1b
				
			
							
								
								
									
										37
									
								
								examples/c++/logger.cxx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								examples/c++/logger.cxx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| #include <thread> | ||||
| #include <vector> | ||||
|  | ||||
| #include "upm_logger.hpp" | ||||
|  | ||||
| using namespace upm; | ||||
|  | ||||
| void print() | ||||
| { | ||||
|   UPM_LOG(LOG_DEBUG) << "Thread " << std::this_thread::get_id() << ": running loop with 3 iterations"; | ||||
|  | ||||
|   for (int i = 0; i < 4; ++i) { | ||||
|     UPM_LOG(LOG_DEBUG) << std::this_thread::get_id() << ": i = " << i; | ||||
|   } | ||||
| } | ||||
|  | ||||
| int main() | ||||
| { | ||||
|   std::vector<std::thread> threads; | ||||
|  | ||||
|   UPM_LOGGER::LogLevel() = LOG_ERROR; | ||||
|  | ||||
|   //UPM_LOGGER::outputFile() = "test.log"; | ||||
|  | ||||
|   UPM_LOG(LOG_WARNING) << "Testing the upm logger 1 " << "4"; | ||||
|  | ||||
|   // Launching 5 threads | ||||
|   for (int i = 0; i < 3; ++i) { | ||||
|     threads.push_back(std::thread(print)); | ||||
|   } | ||||
|  | ||||
|   for (auto& thread : threads) { | ||||
|     thread.join(); | ||||
|   } | ||||
|  | ||||
|   return 0; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user