Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
logger.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 NVIDIA Corporation
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __LOGGER_H__
19#define __LOGGER_H__
20
21#include <iostream>
22#include <memory>
23#include <fstream>
24
25#define LOG_TAG() (std::string(__func__ + ":" + __LINE__ + " "))
26
27namespace p2p {
28 // @class Logger
29 // @brief Singleton class for the logging per rank.
30 //
31 // The class is wrapper around the std::ofstream. It logs the messages from
32 // worker, client and server threads at pre-configured tmp location. If
33 // there are more than one rank per node, it is ensured that each rank has
34 // its own log file. This avoid polluting to standard output/err with
35 // messeges otherwise needed for debugging.
36 //
37 // The other option to use is to use the Realm's logger if it is reasonable
38 // to instantiate the Realm's logger inside p2p bootstrap library.
39 class Logger {
40 public:
41 using p2p_log = std::ofstream;
42
43 private:
44 static std::shared_ptr<p2p_log> instance_;
45 // static p2p_log* instance;
46 Logger() {} // Private constructor to prevent direct instantiation
47
48 public:
49 // static p2p_log* getInstance(int rank=0);
50 static std::shared_ptr<p2p_log> getInstance(int rank = 0);
51 };
52} // namespace p2p
53
54#endif
Definition logger.h:39
std::ofstream p2p_log
Definition logger.h:41
static std::shared_ptr< p2p_log > getInstance(int rank=0)
Definition logger.h:27