mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:42:44 +00:00 
			
		
		
		
	 9a120d7243
			
		
	
	
		9a120d7243
		
	
	
	
	
		
			
			These are formatters that can only be used with debug print
functions, such as dbgln(). Currently this is limited to
Formatter<ErrorOr<T>>. With this you can still debug log ErrorOr
values (good for debugging), but trying to use them in any
String::formatted() call will fail (which prevents .to_string()
errors with the new failable strings being ignored).
You make a formatter debug only by adding a constexpr method like:
static constexpr bool is_debug_only() { return true; }
		
	
			
		
			
				
	
	
		
			22 lines
		
	
	
	
		
			490 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
	
		
			490 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020, the SerenityOS developers.
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Format.h>
 | |
| 
 | |
| extern bool g_report_to_debug;
 | |
| 
 | |
| template<typename... Ts>
 | |
| void reportln(StringView format, Ts... args)
 | |
| {
 | |
|     if (g_report_to_debug) {
 | |
|         AK::VariadicFormatParams<AK::AllowDebugOnlyFormatters::Yes, Ts...> variadic_format_params { args... };
 | |
|         AK::vdbgln(format, variadic_format_params);
 | |
|     } else {
 | |
|         warnln(format, args...);
 | |
|     }
 | |
| }
 |