Skip to content

Commit 844afc1

Browse files
committed
Add logging files
1 parent 916052b commit 844afc1

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

cpp2rust/logging.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
#include "logging.h"
5+
6+
namespace cpp2rust {
7+
namespace {
8+
llvm::raw_ostream *verrs_ = &llvm::nulls();
9+
llvm::raw_ostream *vouts_ = &llvm::nulls();
10+
} // namespace
11+
12+
void SetVerbose(bool verbose) {
13+
verrs_ = verbose ? &llvm::errs() : &llvm::nulls();
14+
vouts_ = verbose ? &llvm::outs() : &llvm::nulls();
15+
}
16+
17+
llvm::raw_ostream &verrs() { return *verrs_; }
18+
llvm::raw_ostream &vouts() { return *vouts_; }
19+
20+
} // namespace cpp2rust

cpp2rust/logging.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2022-present INESC-ID.
2+
// Distributed under the MIT license that can be found in the LICENSE file.
3+
4+
#pragma once
5+
6+
#include <llvm/Support/raw_ostream.h>
7+
8+
namespace cpp2rust {
9+
10+
void SetVerbose(bool verbose);
11+
12+
llvm::raw_ostream &verrs();
13+
llvm::raw_ostream &vouts();
14+
15+
} // namespace cpp2rust

0 commit comments

Comments
 (0)