guts
gutsConventions.cc
Go to the documentation of this file.
1 // conventions
2 #include "gutsConventions.h"
3 
4 // thread safe message systems
5 
6 #include <mutex>
7 std::mutex mu;
8 
9 // c++
10 #include <iostream>
11 using namespace std;
12 
13 // exiting with error, print error on screen.
14 void gexit(int error) {
15  mu.lock();
16  if ( error != EXIT_SUCCESS ) {
17  cerr << KBOLD << KRED << " Exiting with error " << error << RST << endl;
18  }
19  mu.unlock();
20  exit(error);
21 }
22 
23 // class constructor
24 void gLogClassConstruct(string className) {
25  mu.lock();
26  cout << KGRN << CONSTRUCTORLOG << className << KWHT << " class constructor" << RST << endl;
27  mu.unlock();
28 }
29 
30 // copy constructor
31 void gLogCopyConstruct(string className) {
32  mu.lock();
33  cout << KGRN << CONSTRUCTORLOG << className << KWHT << " copy constructor" << RST << endl;
34  mu.unlock();
35 }
36 
37 // move constructor
38 void gLogMoveConstruct(string className) {
39  mu.lock();
40  cout << KBLU << CONSTRUCTORLOG << className << KWHT << " move constructor" << RST << endl;
41  mu.unlock();
42 }
43 
44 // destructor
45 void gLogClassDestruct(string className) {
46  mu.lock();
47  cout << KRED << DESTRUCTORLOG << className << KWHT << " destructor" << RST << endl;
48  mu.unlock();
49 }
50 
51 void gLogMessage(string message) {
52  mu.lock();
53  cout << message << endl;
54  mu.unlock();
55 }
void gLogMoveConstruct(string className)
Logs the move construction of a class instance.
void gLogMessage(string message)
Logs a message.
void gLogCopyConstruct(string className)
Logs the copy construction of a class instance.
void gLogClassDestruct(string className)
Logs the destruction of a class instance.
std::mutex mu
void gexit(int error)
Thread-safe exit function with error code.
void gLogClassConstruct(string className)
Logs the construction of a class instance.
#define KBLU
ANSI code for blue colored text.
#define DESTRUCTORLOG
Log symbol for destructor.
#define CONSTRUCTORLOG
Log symbol for constructor.
#define KRED
ANSI code for red colored text.
#define KBOLD
ANSI code for bold text.
#define KGRN
ANSI code for green colored text.
#define RST
ANSI code to reset text formatting.
#define KWHT
ANSI code for white colored text.