PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
io.cpp
Go to the documentation of this file.
1
2// Copyright (c) 2021 Prashant K. Jha
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6// ////////////////////////////////////////////////////////////////////////////////
7
8#include "io.h"
9#include <cassert>
10
11namespace {
13}
14
15void util::io::initLogger(int debug_level, std::string filename) {
16
17 if (logger_p != nullptr)
18 return;
19
20 auto deck = new LoggerDeck(debug_level, filename);
21 logger_p = new Logger(deck);
22}
23
24void util::io::log(const std::string & str, bool screen_out, int printMpiRank) {
25
26 // for now, we do not call assert and rather create a logger if it does not exist
27 /*
28 //assert((logger_p != nullptr) && "logger_p "
29 // "(pointer of type util::io::Logger) is not initialized. "
30 // "Call util::io::initLogger(debug_level, log_filename) once at the beginning.");
31 */
32 if (logger_p == nullptr)
33 logger_p = new Logger();
34
35 logger_p->log(str, screen_out, printMpiRank);
36}
37
38void util::io::log(std::ostringstream &oss, bool screen_out, int printMpiRank) {
39
40 // for now, we do not call assert and rather create a logger if it does not exist
41 /*
42 //assert((logger_p != nullptr) && "logger_p "
43 // "(pointer of type util::io::Logger) is not initialized. "
44 // "Call util::io::initLogger(debug_level, log_filename) once at the beginning.");
45 */
46 if (logger_p == nullptr)
47 logger_p = new Logger();
48
49 logger_p->log(oss, screen_out, printMpiRank);
50}
Prints log to std::cout and also write to the file.
Definition io.h:251
void log(std::ostringstream &oss, bool screen_out=false, int printMpiRank=print_default_mpi_rank)
Log the message.
Definition io.h:282
util::io::Logger * logger_p
Definition io.cpp:12
void initLogger(int debug_level=logger_default_debug_lvl, std::string filename="")
Initializes the logger.
Definition io.cpp:15
void log(std::ostringstream &oss, bool screen_out=false, int printMpiRank=print_default_mpi_rank)
Global method to log the message.
Definition io.cpp:38
Deck to store log parameters.
Definition io.h:217