1//===-- DAPLog.cpp --------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "DAPLog.h"
10#include "llvm/ADT/StringRef.h"
11#include "llvm/Support/raw_ostream.h"
12#include <chrono>
13#include <mutex>
14#include <system_error>
15
16using namespace llvm;
17
18namespace lldb_dap {
19
20Log::Log(StringRef filename, std::error_code &EC) : m_stream(filename, EC) {}
21
22void Log::WriteMessage(StringRef message) {
23 std::lock_guard<std::mutex> lock(m_mutex);
24 std::chrono::duration<double> now{
25 std::chrono::system_clock::now().time_since_epoch()};
26 m_stream << formatv(Fmt: "{0:f9} ", Vals: now.count()).str() << message << "\n";
27 m_stream.flush();
28}
29
30} // namespace lldb_dap
31

source code of lldb/tools/lldb-dap/DAPLog.cpp