1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "tools/cddl/logging.h" 6 7 // static Abort(const char * condition)8void Logger::Abort(const char* condition) { 9 std::cerr << "CHECK(" << condition << ") failed!" << std::endl; 10 std::abort(); 11 } 12 InitializeInstance()13void Logger::InitializeInstance() { 14 is_initialized_ = true; 15 16 WriteLog("CDDL GENERATION TOOL"); 17 WriteLog("---------------------------------------------\n"); 18 } 19 VerifyInitialized()20void Logger::VerifyInitialized() { 21 if (!is_initialized_) { 22 InitializeInstance(); 23 } 24 } 25 MakePrintable(const std::string & data)26const char* Logger::MakePrintable(const std::string& data) { 27 return data.c_str(); 28 } 29 Logger()30Logger::Logger() { 31 is_initialized_ = false; 32 } 33 34 // Static: Get()35Logger* Logger::Get() { 36 return Logger::singleton_; 37 } 38 39 // Static: 40 Logger* Logger::singleton_ = new Logger(); 41