Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cLogAppendConsole.h
Go to the documentation of this file.
1 //
5 //
6 
7 #ifndef _INC_cLogAppendConsole_H
8 #define _INC_cLogAppendConsole_H
9 #ifndef NO_PRAGMA_ONCE
10 #pragma once
11 #endif
12 
13 #include "cLogAppender.h"
14 #include "cArrayString.h"
15 #include "cSingletonPtr.h"
16 
17 #if !defined(UNDER_CE) && USE_CRT
18 
19 namespace Gray
20 {
21  class GRAYCORE_LINK cLogAppendConsole : public cLogAppender, public cSingletonSmart<cLogAppendConsole>
22  {
26  public:
28  virtual ~cLogAppendConsole();
29 
30  virtual HRESULT WriteString(const LOGCHAR_t* pszMsg) override;
31 
32  static HRESULT GRAYCALL AddAppenderCheck(cLogNexus* pLogger = nullptr, bool bAttachElseAlloc = false);
33  static bool GRAYCALL RemoveAppenderCheck(cLogNexus* pLogger, bool bOnlyIfParent);
34 
35  static HRESULT GRAYCALL ShowMessageBox(cString sMsg, UINT uFlags = 1); // 1= MB_OKCANCEL
37 
40  };
41 
43  {
46  public:
48  const ITERATE_t m_iMax;
49 
50  public:
51  cLogAppendTextArray(ITERATE_t iMax = SHRT_MAX)
52  : m_iMax(iMax)
53  {
54  }
55  virtual HRESULT WriteString(const LOGCHAR_t* pszMsg) override
56  {
57  if (StrT::IsNullOrEmpty(pszMsg))
58  return 0;
59  if (m_aMsgs.GetSize() >= m_iMax)
60  return 0;
61  m_aMsgs.Add(pszMsg);
62  return 1;
63  }
65  };
66 }
67 #endif
68 #endif // _INC_cLogAppendConsole_H
#define GRAYCORE_LINK
Definition: GrayCore.h:47
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define IUNKNOWN_DISAMBIG(TYPE)
Definition: IUnknown.h:92
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define CHEAPOBJECT_IMPL
Definition: cHeapObject.h:32
ITERATE_t Add(ARG_TYPE newElement)
Definition: cArray.h:199
ITERATE_t GetSize() const noexcept
Definition: cArray.h:137
Definition: cLogAppendConsole.h:22
static HRESULT __stdcall ShowMessageBox(cString sMsg, UINT uFlags=1)
static HRESULT __stdcall WaitForDebugger()
static bool __stdcall RemoveAppenderCheck(cLogNexus *pLogger, bool bOnlyIfParent)
virtual HRESULT WriteString(const LOGCHAR_t *pszMsg) override
static HRESULT __stdcall AddAppenderCheck(cLogNexus *pLogger=nullptr, bool bAttachElseAlloc=false)
Definition: cLogAppendConsole.h:43
virtual HRESULT WriteString(const LOGCHAR_t *pszMsg) override
Definition: cLogAppendConsole.h:55
cArrayString< LOGCHAR_t > m_aMsgs
Definition: cLogAppendConsole.h:47
cLogAppendTextArray(ITERATE_t iMax=SHRT_MAX)
Definition: cLogAppendConsole.h:51
const ITERATE_t m_iMax
Store this many messages.
Definition: cLogAppendConsole.h:48
Definition: cLogAppender.h:257
Definition: cLogMgr.h:52
Definition: cRefPtr.h:22
Definition: cSingletonPtr.h:20
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
int ITERATE_t
like size_t but signed
Definition: Index.h:28
char LOGCHAR_t
always just use UTF8 for logs, don't bother with UNICODE.
Definition: cLogLevel.h:17
static bool IsNullOrEmpty(const TYPE *pszStr) noexcept
Definition: StrT.h:102