]> git.donarmstrong.com Git - mothur.git/blob - mothurout.cpp
adding mothurout.h and .cpp to repo
[mothur.git] / mothurout.cpp
1 /*
2  *  m->mothurOut.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 2/25/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "mothurout.h"
11
12 /******************************************************/
13 MothurOut* MothurOut::getInstance() {
14         if( _uniqueInstance == 0) {
15                 _uniqueInstance = new MothurOut();
16         }
17         return _uniqueInstance;
18 }
19 /*********************************************************************************************/
20 void MothurOut::setFileName(string filename)  {
21         try {
22                 logFileName = filename;
23                 openOutputFile(filename, out);
24         }
25         catch(exception& e) {
26                 errorOut(e, "MothurOut", "setFileName");
27                 exit(1);
28         }
29 }
30 /*********************************************************************************************/
31 MothurOut::~MothurOut() {
32         try {
33                 _uniqueInstance = 0;
34                 out.close();
35         }
36         catch(exception& e) {
37                 errorOut(e, "MothurOut", "MothurOut");
38                 exit(1);
39         }
40 }
41
42 /*********************************************************************************************/
43 void MothurOut::mothurOut(string output) {
44         try {
45         
46                 cout << output;
47                 out << output;
48                 
49         }
50         catch(exception& e) {
51                 errorOut(e, "MothurOut", "MothurOut");
52                 exit(1);
53         }
54 }
55 /*********************************************************************************************/
56 void MothurOut::mothurOutEndLine() {
57         try {
58                 cout << endl;
59                 out << endl;
60         }
61         catch(exception& e) {
62                 errorOut(e, "MothurOut", "MothurOutEndLine");
63                 exit(1);
64         }
65 }
66 /*********************************************************************************************/
67 void MothurOut::mothurOutJustToLog(string output) {
68         try {
69                 out << output;
70         }
71         catch(exception& e) {
72                 errorOut(e, "MothurOut", "MothurOutJustToLog");
73                 exit(1);
74         }
75 }
76 /*********************************************************************************************/
77 void MothurOut::errorOut(exception& e, string object, string function) {
78         mothurOut("Error: ");
79         mothurOut(toString(e.what()));
80         mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry.");
81         mothurOutEndLine();
82 }
83 /*********************************************************************************************/
84
85
86
87
88