diff options
Diffstat (limited to 'Source/CPack/cmCPackLog.cxx')
-rw-r--r-- | Source/CPack/cmCPackLog.cxx | 180 |
1 files changed, 75 insertions, 105 deletions
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 61d97c8..ff06eb8 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -39,37 +39,33 @@ cmCPackLog::~cmCPackLog() void cmCPackLog::SetLogOutputStream(std::ostream* os) { - if ( this->LogOutputCleanup && this->LogOutput ) - { + if (this->LogOutputCleanup && this->LogOutput) { delete this->LogOutput; - } + } this->LogOutputCleanup = false; this->LogOutput = os; } bool cmCPackLog::SetLogOutputFile(const char* fname) { - cmGeneratedFileStream *cg = 0; - if ( fname ) - { + cmGeneratedFileStream* cg = 0; + if (fname) { cg = new cmGeneratedFileStream(fname); - } - if ( cg && !*cg ) - { + } + if (cg && !*cg) { delete cg; cg = 0; - } + } this->SetLogOutputStream(cg); - if ( !cg ) - { + if (!cg) { return false; - } + } this->LogOutputCleanup = true; return true; } -void cmCPackLog::Log(int tag, const char* file, int line, - const char* msg, size_t length) +void cmCPackLog::Log(int tag, const char* file, int line, const char* msg, + size_t length) { // By default no logging bool display = false; @@ -77,144 +73,118 @@ void cmCPackLog::Log(int tag, const char* file, int line, // Display file and line number if debug bool useFileAndLine = this->Debug; - bool output = false; - bool debug = false; + bool output = false; + bool debug = false; bool warning = false; - bool error = false; + bool error = false; bool verbose = false; // When writing in file, add list of tags whenever tag changes. std::string tagString; bool needTagString = false; - if ( this->LogOutput && this->LastTag != tag ) - { + if (this->LogOutput && this->LastTag != tag) { needTagString = true; - } + } - if ( tag & LOG_OUTPUT ) - { + if (tag & LOG_OUTPUT) { output = true; display = true; - if ( needTagString ) - { - if (!tagString.empty()) { tagString += ","; } - tagString = "VERBOSE"; + if (needTagString) { + if (!tagString.empty()) { + tagString += ","; } + tagString = "VERBOSE"; } - if ( tag & LOG_WARNING ) - { + } + if (tag & LOG_WARNING) { warning = true; display = true; - if ( needTagString ) - { - if (!tagString.empty()) { tagString += ","; } - tagString = "WARNING"; + if (needTagString) { + if (!tagString.empty()) { + tagString += ","; } + tagString = "WARNING"; } - if ( tag & LOG_ERROR ) - { + } + if (tag & LOG_ERROR) { error = true; display = true; - if ( needTagString ) - { - if (!tagString.empty()) { tagString += ","; } - tagString = "ERROR"; + if (needTagString) { + if (!tagString.empty()) { + tagString += ","; } + tagString = "ERROR"; } - if ( tag & LOG_DEBUG && this->Debug ) - { + } + if (tag & LOG_DEBUG && this->Debug) { debug = true; display = true; - if ( needTagString ) - { - if (!tagString.empty()) { tagString += ","; } - tagString = "DEBUG"; + if (needTagString) { + if (!tagString.empty()) { + tagString += ","; } - useFileAndLine = true; + tagString = "DEBUG"; } - if ( tag & LOG_VERBOSE && this->Verbose ) - { + useFileAndLine = true; + } + if (tag & LOG_VERBOSE && this->Verbose) { verbose = true; display = true; - if ( needTagString ) - { - if (!tagString.empty()) { tagString += ","; } - tagString = "VERBOSE"; + if (needTagString) { + if (!tagString.empty()) { + tagString += ","; } + tagString = "VERBOSE"; } - if ( this->Quiet ) - { + } + if (this->Quiet) { display = false; + } + if (this->LogOutput) { + if (needTagString) { + *this->LogOutput << "[" << file << ":" << line << " " << tagString + << "] "; } - if ( this->LogOutput ) - { - if ( needTagString ) - { - *this->LogOutput << "[" << file << ":" << line << " " - << tagString << "] "; - } this->LogOutput->write(msg, length); - } + } this->LastTag = tag; - if ( !display ) - { + if (!display) { return; - } - if ( this->NewLine ) - { - if ( error && !this->ErrorPrefix.empty() ) - { + } + if (this->NewLine) { + if (error && !this->ErrorPrefix.empty()) { *this->DefaultError << this->ErrorPrefix; - } - else if ( warning && !this->WarningPrefix.empty() ) - { + } else if (warning && !this->WarningPrefix.empty()) { *this->DefaultError << this->WarningPrefix; - } - else if ( output && !this->OutputPrefix.empty() ) - { + } else if (output && !this->OutputPrefix.empty()) { *this->DefaultOutput << this->OutputPrefix; - } - else if ( verbose && !this->VerbosePrefix.empty() ) - { + } else if (verbose && !this->VerbosePrefix.empty()) { *this->DefaultOutput << this->VerbosePrefix; - } - else if ( debug && !this->DebugPrefix.empty() ) - { + } else if (debug && !this->DebugPrefix.empty()) { *this->DefaultOutput << this->DebugPrefix; - } - else if ( !this->Prefix.empty() ) - { + } else if (!this->Prefix.empty()) { *this->DefaultOutput << this->Prefix; - } - if ( useFileAndLine ) - { - if ( error || warning ) - { + } + if (useFileAndLine) { + if (error || warning) { *this->DefaultError << file << ":" << line << " "; - } - else - { + } else { *this->DefaultOutput << file << ":" << line << " "; - } } } - if ( error || warning ) - { + } + if (error || warning) { this->DefaultError->write(msg, length); this->DefaultError->flush(); - } - else - { + } else { this->DefaultOutput->write(msg, length); this->DefaultOutput->flush(); - } - if ( msg[length-1] == '\n' || length > 2 ) - { + } + if (msg[length - 1] == '\n' || length > 2) { this->NewLine = true; - } + } - if ( error ) - { + if (error) { cmSystemTools::SetErrorOccured(); - } + } } |