log.h 685 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef _LOG_H_
  2. #define _LOG_H_
  3. #ifdef USE_CONSOLEKIT
  4. #include "Ck.h"
  5. #endif
  6. #ifdef USE_PAM
  7. #include "PAM.h"
  8. #endif
  9. #include "const.h"
  10. #include <fstream>
  11. using namespace std;
  12. static class LogUnit {
  13. ofstream logFile;
  14. public:
  15. bool openLog(const char * filename);
  16. void closeLog();
  17. ~LogUnit() { closeLog(); }
  18. template<typename Type>
  19. LogUnit & operator<<(const Type & text) {
  20. logFile << text; logFile.flush();
  21. return *this;
  22. }
  23. LogUnit & operator<<(ostream & (*fp)(ostream&)) {
  24. logFile << fp; logFile.flush();
  25. return *this;
  26. }
  27. LogUnit & operator<<(ios_base & (*fp)(ios_base&)) {
  28. logFile << fp; logFile.flush();
  29. return *this;
  30. }
  31. } logStream;
  32. #endif /* _LOG_H_ */