1#ifndef PROTEUS_LOGGER_HPP
2#define PROTEUS_LOGGER_HPP
11#include <llvm/Support/Error.h>
12#include <llvm/Support/FileSystem.h>
13#include <llvm/Support/raw_ostream.h>
19 static llvm::raw_ostream &
logs(
const std::string &Name) {
20 static Logger SingletonLogger{Name};
21 SingletonLogger.OutStream <<
"[" << Name <<
"] ";
22 return SingletonLogger.OutStream;
25 static llvm::raw_ostream &
outs(
const std::string &Name) {
26 llvm::outs() <<
"[" << Name <<
"] ";
30 static void trace(llvm::StringRef Msg) { std::cout << Msg.str(); }
33 static void logfile(
const std::string &Filename, T &&Data) {
35 llvm::raw_fd_ostream Out(std::string(LogDir) +
"/" +
36 std::to_string(getpid()) +
"." + Filename,
39 throw std::runtime_error(
"Error opening file: " + EC.message());
45 static constexpr char LogDir[] =
".proteus-logs";
48 llvm::raw_fd_ostream OutStream;
50 Logger(
const std::string &Name)
51 : DirExists(
std::filesystem::create_directory(LogDir)),
52 OutStream(
llvm::raw_fd_ostream{
std::string(LogDir) +
"/" + Name +
"." +
53 std::to_string(getpid()) +
".log",
54 EC,
llvm::sys::fs::OF_None}) {
56 throw std::runtime_error(
"Error opening file: " + EC.message());
60 std::ios::sync_with_stdio(
true);
static llvm::raw_ostream & outs(const std::string &Name)
Definition Logger.hpp:25
static void trace(llvm::StringRef Msg)
Definition Logger.hpp:30
static llvm::raw_ostream & logs(const std::string &Name)
Definition Logger.hpp:19
static void logfile(const std::string &Filename, T &&Data)
Definition Logger.hpp:33
Definition BuiltinsCUDA.cpp:4
Definition Hashing.hpp:147