5 * Created by westcott on 2/25/10.
\r
6 * Copyright 2010 Schloss Lab. All rights reserved.
\r
10 #include "mothurout.h"
\r
12 /******************************************************/
\r
13 MothurOut* MothurOut::getInstance() {
\r
14 if( _uniqueInstance == 0) {
\r
15 _uniqueInstance = new MothurOut();
\r
17 return _uniqueInstance;
\r
19 /*********************************************************************************************/
\r
20 void MothurOut::setFileName(string filename) {
\r
22 logFileName = filename;
\r
26 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
\r
28 if (pid == 0) { //only one process should output to screen
\r
31 openOutputFile(filename, out);
\r
37 catch(exception& e) {
\r
38 errorOut(e, "MothurOut", "setFileName");
\r
42 /*********************************************************************************************/
\r
43 void MothurOut::closeLog() {
\r
48 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
\r
50 if (pid == 0) { //only one process should output to screen
\r
59 catch(exception& e) {
\r
60 errorOut(e, "MothurOut", "closeLog");
\r
65 /*********************************************************************************************/
\r
66 MothurOut::~MothurOut() {
\r
68 _uniqueInstance = 0;
\r
71 catch(exception& e) {
\r
72 errorOut(e, "MothurOut", "MothurOut");
\r
76 /*********************************************************************************************/
\r
77 void MothurOut::mothurOut(string output) {
\r
82 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
\r
84 if (pid == 0) { //only one process should output to screen
\r
94 catch(exception& e) {
\r
95 errorOut(e, "MothurOut", "MothurOut");
\r
99 /*********************************************************************************************/
\r
100 void MothurOut::mothurOutEndLine() {
\r
104 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
\r
106 if (pid == 0) { //only one process should output to screen
\r
116 catch(exception& e) {
\r
117 errorOut(e, "MothurOut", "MothurOutEndLine");
\r
121 /*********************************************************************************************/
\r
122 void MothurOut::mothurOutJustToLog(string output) {
\r
126 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
\r
128 if (pid == 0) { //only one process should output to screen
\r
137 catch(exception& e) {
\r
138 errorOut(e, "MothurOut", "MothurOutJustToLog");
\r
142 /*********************************************************************************************/
\r
143 void MothurOut::errorOut(exception& e, string object, string function) {
\r
144 mothurOut("Error: ");
\r
145 mothurOut(toString(e.what()));
\r
146 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.");
\r
147 mothurOutEndLine();
\r
149 /*********************************************************************************************/
\r