Teamcenter C++ API Reference  2312
Appender.hxx
Go to the documentation of this file.
1 // Copyright 2022 Siemens Digital Industries Software
2 // ==================================================
3 // Copyright 2022.
4 // Siemens Product Lifecycle Management Software Inc.
5 // All Rights Reserved.
6 // ==================================================
7 // Copyright 2022 Siemens Digital Industries Software
8 
9 #ifndef TEAMCENTER_COMMON_LOGGING_APPENDER_HXX
10 #define TEAMCENTER_COMMON_LOGGING_APPENDER_HXX
11 
12 #include <tclogging/Logger.hxx>
13 
14 #include <string>
15 #include <stdio.h>
16 
17 #include <tclogging/libtclogging_exports.h>
18 
19 namespace Teamcenter::Common::Logging
20 {
21  struct LogEvent
22  {
26  std::string& loggerName;
28  const char* fileName;
30  int line;
32  int errorCode;
34  const std::string& message;
35  };
36 
41  class TCLOGGING_API Appender
42  {
43  public:
51  static void includeLoggerName( bool include );
52 
53 
54 
55  virtual ~Appender() = default;
56  Appender() = default;
57  Appender( const Appender& ) = delete;
58  Appender( Appender&& ) = delete;
59  Appender& operator=( const Appender& ) = delete;
60  Appender& operator=( Appender&& ) = delete;
61 
62  virtual std::string getAbsoluteFilePath() = 0;
63 
67  FILE* getFilePointer();
68 
69  private:
70  friend class Logger;
71  friend class FileAppenderTest;
72 
73  static std::string getCurrentTimeStamp();
74  void formatLogEvent( LogEvent logEvent, std::ostringstream& stringStream );
75 
76  protected:
77  FILE* fp = NULL;
78 
79  void write( const LogEvent& event );
80  };
81 
82 }
83 
84 #include <tclogging/libtclogging_undef.h>
85 #endif