5 * Created by westcott on 2/25/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
10 #include "mothurout.h"
12 /******************************************************/
13 MothurOut* MothurOut::getInstance() {
14 if( _uniqueInstance == 0) {
15 _uniqueInstance = new MothurOut();
17 return _uniqueInstance;
19 /*********************************************************************************************/
20 void MothurOut::setFileName(string filename) {
22 logFileName = filename;
26 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
28 if (pid == 0) { //only one process should output to screen
31 openOutputFile(filename, out);
38 errorOut(e, "MothurOut", "setFileName");
42 /*********************************************************************************************/
43 MothurOut::~MothurOut() {
49 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
51 if (pid == 0) { //only one process should output to screen
61 errorOut(e, "MothurOut", "MothurOut");
66 /*********************************************************************************************/
67 void MothurOut::mothurOut(string output) {
72 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
74 if (pid == 0) { //only one process should output to screen
85 errorOut(e, "MothurOut", "MothurOut");
89 /*********************************************************************************************/
90 void MothurOut::mothurOutEndLine() {
94 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
96 if (pid == 0) { //only one process should output to screen
106 catch(exception& e) {
107 errorOut(e, "MothurOut", "MothurOutEndLine");
111 /*********************************************************************************************/
112 void MothurOut::mothurOutJustToLog(string output) {
116 MPI_Comm_rank(MPI_COMM_WORLD, &pid);
118 if (pid == 0) { //only one process should output to screen
127 catch(exception& e) {
128 errorOut(e, "MothurOut", "MothurOutJustToLog");
132 /*********************************************************************************************/
133 void MothurOut::errorOut(exception& e, string object, string function) {
134 mothurOut("Error: ");
135 mothurOut(toString(e.what()));
136 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.");
139 /*********************************************************************************************/