Galerkin FEM for elliptic PDEs
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

logging.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // ===========================================================================
  2. //
  3. // Filename: logging.cpp
  4. //
  5. // Description:
  6. //
  7. // Version: 0.0
  8. // Created: 09/12/2013 03:26:27 PM
  9. // Revision: none
  10. // Compiler: Tested with g++
  11. //
  12. // Author: M. Andy Kass (MAK)
  13. //
  14. // Organisation: US Geological Survey
  15. //
  16. //
  17. // Email: mkass@usgs.gov
  18. //
  19. // This program is free software: you can redistribute it and/or modify
  20. // it under the terms of the GNU General Public License as published by
  21. // the Free Software Foundation, either version 3 of the License, or
  22. // (at your option) any later version.
  23. //
  24. // This program is distributed in the hope that it will be useful,
  25. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. // GNU General Public License for more details.
  28. //
  29. // You should have received a copy of the GNU General Public License
  30. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  31. //
  32. // ===========================================================================
  33. #include "logging.h"
  34. namespace formalhaut {
  35. std::ostream &operator<<(std::ostream &stream,
  36. const Logging &ob) {
  37. stream << "Class: Logging\n";
  38. stream << "Output file: " << ob.LogFile << "\n";
  39. stream << "\n";
  40. return stream;
  41. }
  42. Logging* Logging::New() {
  43. return new Logging;
  44. }
  45. void Logging::Delete() {
  46. if (this->outfile.is_open()) {
  47. this->outfile.close();
  48. }
  49. delete this;
  50. }
  51. Logging::Logging() {
  52. }
  53. Logging::~Logging() {
  54. }
  55. void Logging::CloseLogFile() {
  56. if (this->outfile.is_open()) {
  57. this->outfile.close();
  58. }
  59. }
  60. void Logging::WriteLogLine(const std::string line) {
  61. this->outfile << line << std::endl;
  62. }
  63. void Logging::WriteHeader(const std::string& name, const
  64. std::string& ver) {
  65. this->outfile << name << std::endl;
  66. this->outfile << "version " << ver << std::endl << std::endl;
  67. this->outfile << "Run began at " << this->GetDateTime()
  68. << std::endl << std::endl;
  69. }
  70. std::string Logging::GetDateTime() {
  71. time_t now = time(0);
  72. struct tm tstruct;
  73. char buf[80];
  74. tstruct = *localtime(&now);
  75. strftime(buf,sizeof(buf),"%Y-%m-%d.%X",&tstruct);
  76. return buf;
  77. }
  78. void Logging::WriteCloser() {
  79. this->outfile << "Successfully ended at " << this->GetDateTime()
  80. << std::endl;
  81. this->outfile.close();
  82. }
  83. void Logging::WriteDashedLine() {
  84. std::string dashes;
  85. dashes = "------------------------------------";
  86. dashes = dashes + dashes;
  87. this->outfile << dashes << std::endl;
  88. }
  89. void Logging::SetLogFile(const std::string& fname) {
  90. this->LogFile = fname;
  91. this->outfile.open(this->LogFile.c_str());
  92. }
  93. std::string Logging::GetLogFile() {
  94. return this->LogFile;
  95. }
  96. } // end of namespace formalhaut