Sequential Quantum Gate Decomposer  v1.8.8
Powerful decomposition of general unitarias into one- and two-qubit gates gates
logging.cpp
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright 2020 Peter Rakyta, Ph.D.
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 @author: Peter Rakyta, Ph.D.
19 */
24 #include "logging.h"
25 
26 
27 
35 
36  // Number of the verbosity level in order to control the amount of the output messages. If this value is higher or equal than the local verbosity levels belongs to the messages, than the messages will be seen on the standart output screen.
37  verbose=3;
38 
39 
40 
41  // Logical variable. Set true to write output messages to a user defined file.
42 
43  debug=false;
44 
45 
46 }
47 
48 
49 
55 void logging::print(const std::stringstream& sstream, int verbose_level) const {
56 
57 
58  if (debug) {
59 
60  std::ofstream debug_file;
61  debug_file.open(debugfile_name, std::ios_base::app);
62  debug_file << sstream.str();
63  debug_file.close();
64  }
65 
66 
67  if (verbose_level<=verbose) {
68  std::cout << sstream.str();
69  fflush(stdout);
70  }
71 
72 
73 
74 
75 
76 }
77 
78 
79 
80 
85 void logging::set_verbose( int verbose_in ) {
86 
87  verbose = verbose_in;
88 
89 }
90 
95 void logging::set_debugfile(std::string debugfile ) {
96 
97  debugfile_name = debugfile;
98 
99  if (debugfile_name!="<NULL>")
100  debug=true;
101 
102  if (debugfile_name.c_str()) std::remove(debugfile_name.c_str());
103 
104 }
105 
void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
Definition: logging.cpp:55
Header file for a class containing basic methods for setting up the verbosity level.
bool debug
Logical variable. Set true to write output messages to the &#39;debug.txt&#39; file.
Definition: logging.h:53
void set_debugfile(std::string debugfile)
Call to set the debugfile name.
Definition: logging.cpp:95
int verbose
Set the verbosity level of the output messages.
Definition: logging.h:50
std::string debugfile_name
String variable. Set the debug file name.
Definition: logging.h:56
void set_verbose(int verbose_in)
Call to set the verbose attribute.
Definition: logging.cpp:85
logging()
Nullary constructor of the class.
Definition: logging.cpp:34