summaryrefslogtreecommitdiffabout
path: root/LogPattern.cpp
authorMichael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
committer Michael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
commita1487b3fc0313408525cd5b2f3bc4a462df351f7 (patch) (side-by-side diff)
tree010aec6c2abd5ada2f909ac6798c93bf22508bf5 /LogPattern.cpp
downloadklog-a1487b3fc0313408525cd5b2f3bc4a462df351f7.zip
klog-a1487b3fc0313408525cd5b2f3bc4a462df351f7.tar.gz
klog-a1487b3fc0313408525cd5b2f3bc4a462df351f7.tar.bz2
initial commit into svn repository
git-svn-id: http://svn.klever.net/kin/klog/trunk@1 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (limited to 'LogPattern.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--LogPattern.cpp157
1 files changed, 157 insertions, 0 deletions
diff --git a/LogPattern.cpp b/LogPattern.cpp
new file mode 100644
index 0000000..649fe52
--- a/dev/null
+++ b/LogPattern.cpp
@@ -0,0 +1,157 @@
+// LogPattern.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "KLog.h"
+#include "SyslogSocket.h"
+#include "LogPattern.h"
+
+#include "LogPatternUnix.h"
+#include "LogPatternReserved.h"
+#include "LogPatternLocal.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CLogPattern
+
+UINT CLogPattern::m_ID[CSyslogSocket::totalFacilities][CSyslogSocket::totalPriorities] = {
+ // Unix
+ { IDC_KERNEL_EMERG,IDC_KERNEL_ALERT,IDC_KERNEL_CRIT,IDC_KERNEL_ERR,IDC_KERNEL_WARN,IDC_KERNEL_NOTICE,IDC_KERNEL_INFO,IDC_KERNEL_DEBUG },
+ { IDC_USER_EMERG,IDC_USER_ALERT,IDC_USER_CRIT,IDC_USER_ERR,IDC_USER_WARN,IDC_USER_NOTICE,IDC_USER_INFO,ID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_WARN,IDC_L4_NOTICE,IDC_L4_INFO,IDC_L4_DEBUG },
+ { IDC_L5_EMERG,IDC_L5_ALERT,IDC_L5_CRIT,IDC_L5_ERR,IDC_L5_WARN,IDC_L5_NOTICE,IDC_L5_INFO,IDC_L5_DEBUG },
+ { IDC_L6_EMERG,IDC_L6_ALERT,IDC_L6_CRIT,IDC_L6_ERR,IDC_L6_WARN,IDC_L6_NOTICE,IDC_L6_INFO,IDC_L6_DEBUG },
+ { IDC_L7_EMERG,IDC_L7_ALERT,IDC_L7_CRIT,IDC_L7_ERR,IDC_L7_WARN,IDC_L7_NOTICE,IDC_L7_INFO,IDC_L7_DEBUG }
+};
+
+IMPLEMENT_DYNAMIC(CLogPattern, CPropertySheet)
+
+CLogPattern::CLogPattern(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
+ :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
+{
+ AddPages();
+}
+
+CLogPattern::CLogPattern(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
+ :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
+{
+ AddPages();
+}
+
+CLogPattern::~CLogPattern()
+{
+ delete m_Unix;
+ delete m_Reserved;
+ delete m_Local;
+}
+
+
+BEGIN_MESSAGE_MAP(CLogPattern, CPropertySheet)
+ //{{AFX_MSG_MAP(CLogPattern)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CLogPattern message handlers
+
+void CLogPattern::AddPages()
+{
+ m_Unix = new CLogPatternUnix(this);
+ ASSERT(m_Unix);
+ AddPage(m_Unix);
+ m_Reserved = new CLogPatternReserved(this);
+ ASSERT(m_Reserved);
+ AddPage(m_Reserved);
+ m_Local = new CLogPatternLocal(this);
+ ASSERT(m_Local);
+ AddPage(m_Local);
+}
+
+void CLogPattern::ExchangeData(CDataExchange *pDX,UINT from,UINT to)
+{
+ if(pDX->m_bSaveAndValidate){
+ for(UINT f=from;f<=to;f++){
+ for(UINT p=0;p<CSyslogSocket::totalPriorities;p++){
+ switch(pDX->m_pDlgWnd->IsDlgButtonChecked(m_ID[f][p])){
+ case 0:
+ m_Pattern[f][p]=FALSE;
+ break;
+ case 1:
+ m_Pattern[f][p]=TRUE;
+ break;
+#ifndef NDEBUG
+ default:
+ ASSERT(FALSE);
+ break;
+#endif
+ }
+ }
+ }
+ }else{
+ for(UINT f=from;f<=to;f++){
+ for(UINT p=0;p<CSyslogSocket::totalPriorities;p++){
+ pDX->m_pDlgWnd->CheckDlgButton(m_ID[f][p],m_Pattern[f][p]?1:0);
+ }
+ }
+ }
+}
+
+void CLogPattern::PriorityOn(CWnd *pWnd,UINT pri,UINT from,UINT to)
+{
+ for(UINT f=from;f<=to;f++)
+ pWnd->CheckDlgButton(m_ID[f][pri],1);
+}
+
+void CLogPattern::PriorityXor(CWnd *pWnd,UINT pri,UINT from,UINT to)
+{
+ for(UINT f=from;f<=to;f++)
+ pWnd->CheckDlgButton(m_ID[f][pri],pWnd->IsDlgButtonChecked(m_ID[f][pri])?0:1);
+}
+
+void CLogPattern::FacilityOn(CWnd *pWnd,UINT fac)
+{
+ for(int p=0;p<CSyslogSocket::totalPriorities;p++)
+ pWnd->CheckDlgButton(m_ID[fac][p],1);
+}
+
+void CLogPattern::FacilityXor(CWnd *pWnd,UINT fac)
+{
+ for(int p=0;p<CSyslogSocket::totalPriorities;p++)
+ pWnd->CheckDlgButton(m_ID[fac][p],pWnd->IsDlgButtonChecked(m_ID[fac][p])?0:1);
+}
+
+void CLogPattern::AddTips(CToolTipCtrl& tt,CWnd *pWnd,UINT from,UINT to)
+{
+CString ttt;
+ for(UINT f=from;f<to;f++){
+ for(UINT p=0;p<CSyslogSocket::totalPriorities;p++){
+ ttt.Format("%s.%s",CSyslogSocket::m_Facilities[f],CSyslogSocket::m_Priorities[p]);
+ tt.AddTool(pWnd->GetDlgItem(m_ID[f][p]),ttt);
+ }
+ }
+}