1 /** 2 Copyright: Copyright (c) 2017, Joakim Brännström. All rights reserved. 3 License: MPL-2 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 6 This Source Code Form is subject to the terms of the Mozilla Public License, 7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 8 one at http://mozilla.org/MPL/2.0/. 9 */ 10 module cpptooling.analyzer.clang.type_logger; 11 12 import clang.Type : Type; 13 14 /// Log a clang Type object if compiled with debug. 15 void logType(ref Type type, in uint indent = 0, string func = __FUNCTION__, uint line = __LINE__) { 16 import std.array : array; 17 import std.range : repeat; 18 import logger = std.experimental.logger; 19 import clang.info : abilities; 20 21 // dfmt off 22 debug { 23 string indent_ = repeat(' ', indent).array(); 24 logger.logf!(-1, "", "", "", "") 25 (logger.LogLevel.trace, 26 "%d%s %s|%s|%s|%s|%s [%s:%d]", 27 indent, 28 indent_, 29 type.cursor.usr, 30 type.kind, 31 abilities(type), 32 type.isValid ? "valid" : "invalid", 33 type.typeKindSpelling, 34 func, 35 line); 36 } 37 // dfmt on 38 }