xref: /aosp_15_r20/external/openscreen/tools/cddl/logging.cc (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
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)8 void Logger::Abort(const char* condition) {
9   std::cerr << "CHECK(" << condition << ") failed!" << std::endl;
10   std::abort();
11 }
12 
InitializeInstance()13 void Logger::InitializeInstance() {
14   is_initialized_ = true;
15 
16   WriteLog("CDDL GENERATION TOOL");
17   WriteLog("---------------------------------------------\n");
18 }
19 
VerifyInitialized()20 void Logger::VerifyInitialized() {
21   if (!is_initialized_) {
22     InitializeInstance();
23   }
24 }
25 
MakePrintable(const std::string & data)26 const char* Logger::MakePrintable(const std::string& data) {
27   return data.c_str();
28 }
29 
Logger()30 Logger::Logger() {
31   is_initialized_ = false;
32 }
33 
34 // Static:
Get()35 Logger* Logger::Get() {
36   return Logger::singleton_;
37 }
38 
39 // Static:
40 Logger* Logger::singleton_ = new Logger();
41