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) (unidiff)
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 @@
1// LogPattern.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "KLog.h"
6#include "SyslogSocket.h"
7#include "LogPattern.h"
8
9#include "LogPatternUnix.h"
10#include "LogPatternReserved.h"
11#include "LogPatternLocal.h"
12
13#ifdef _DEBUG
14#define new DEBUG_NEW
15#undef THIS_FILE
16static char THIS_FILE[] = __FILE__;
17#endif
18
19/////////////////////////////////////////////////////////////////////////////
20// CLogPattern
21
22UINT CLogPattern::m_ID[CSyslogSocket::totalFacilities][CSyslogSocket::totalPriorities] = {
23 // Unix
24 { IDC_KERNEL_EMERG,IDC_KERNEL_ALERT,IDC_KERNEL_CRIT,IDC_KERNEL_ERR,IDC_KERNEL_WARN,IDC_KERNEL_NOTICE,IDC_KERNEL_INFO,IDC_KERNEL_DEBUG },
25 { IDC_USER_EMERG,IDC_USER_ALERT,IDC_USER_CRIT,IDC_USER_ERR,IDC_USER_WARN,IDC_USER_NOTICE,IDC_USER_INFO,IDC_US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WARN,IDC_AUTHPRIV_NOTICE,IDC_AUTHPRIV_INFO,IDC_AUTHPRIV_DEBUG },
35 // Reserved
36 { IDC_R0_EMERG,IDC_R0_ALERT,IDC_R0_CRIT,IDC_R0_ERR,IDC_R0_WARN,IDC_R0_NOTICE,IDC_R0_INFO,IDC_R0_DEBUG },
37 { IDC_R1_EMERG,IDC_R1_ALERT,IDC_R1_CRIT,IDC_R1_ERR,IDC_R1_WARN,IDC_R1_NOTICE,IDC_R1_INFO,IDC_R1_DEBUG },
38 { IDC_R2_EMERG,IDC_R2_ALERT,IDC_R2_CRIT,IDC_R2_ERR,IDC_R2_WARN,IDC_R2_NOTICE,IDC_R2_INFO,IDC_R2_DEBUG },
39 { IDC_R3_EMERG,IDC_R3_ALERT,IDC_R3_CRIT,IDC_R3_ERR,IDC_R3_WARN,IDC_R3_NOTICE,IDC_R3_INFO,IDC_R3_DEBUG },
40 { IDC_R4_EMERG,IDC_R4_ALERT,IDC_R4_CRIT,IDC_R4_ERR,IDC_R4_WARN,IDC_R4_NOTICE,IDC_R4_INFO,IDC_R4_DEBUG },
41 // Local
42 { IDC_L0_EMERG,IDC_L0_ALERT,IDC_L0_CRIT,IDC_L0_ERR,IDC_L0_WARN,IDC_L0_NOTICE,IDC_L0_INFO,IDC_L0_DEBUG },
43 { IDC_L1_EMERG,IDC_L1_ALERT,IDC_L1_CRIT,IDC_L1_ERR,IDC_L1_WARN,IDC_L1_NOTICE,IDC_L1_INFO,IDC_L1_DEBUG },
44 { IDC_L2_EMERG,IDC_L2_ALERT,IDC_L2_CRIT,IDC_L2_ERR,IDC_L2_WARN,IDC_L2_NOTICE,IDC_L2_INFO,IDC_L2_DEBUG },
45 { IDC_L3_EMERG,IDC_L3_ALERT,IDC_L3_CRIT,IDC_L3_ERR,IDC_L3_WARN,IDC_L3_NOTICE,IDC_L3_INFO,IDC_L3_DEBUG },
46 { IDC_L4_EMERG,IDC_L4_ALERT,IDC_L4_CRIT,IDC_L4_ERR,IDC_L4_WARN,IDC_L4_NOTICE,IDC_L4_INFO,IDC_L4_DEBUG },
47 { IDC_L5_EMERG,IDC_L5_ALERT,IDC_L5_CRIT,IDC_L5_ERR,IDC_L5_WARN,IDC_L5_NOTICE,IDC_L5_INFO,IDC_L5_DEBUG },
48 { IDC_L6_EMERG,IDC_L6_ALERT,IDC_L6_CRIT,IDC_L6_ERR,IDC_L6_WARN,IDC_L6_NOTICE,IDC_L6_INFO,IDC_L6_DEBUG },
49 { IDC_L7_EMERG,IDC_L7_ALERT,IDC_L7_CRIT,IDC_L7_ERR,IDC_L7_WARN,IDC_L7_NOTICE,IDC_L7_INFO,IDC_L7_DEBUG }
50};
51
52IMPLEMENT_DYNAMIC(CLogPattern, CPropertySheet)
53
54CLogPattern::CLogPattern(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
55 :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
56{
57 AddPages();
58}
59
60CLogPattern::CLogPattern(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
61 :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
62{
63 AddPages();
64}
65
66CLogPattern::~CLogPattern()
67{
68 delete m_Unix;
69 delete m_Reserved;
70 delete m_Local;
71}
72
73
74BEGIN_MESSAGE_MAP(CLogPattern, CPropertySheet)
75 //{{AFX_MSG_MAP(CLogPattern)
76 //}}AFX_MSG_MAP
77END_MESSAGE_MAP()
78
79/////////////////////////////////////////////////////////////////////////////
80// CLogPattern message handlers
81
82void CLogPattern::AddPages()
83{
84 m_Unix = new CLogPatternUnix(this);
85 ASSERT(m_Unix);
86 AddPage(m_Unix);
87 m_Reserved = new CLogPatternReserved(this);
88 ASSERT(m_Reserved);
89 AddPage(m_Reserved);
90 m_Local = new CLogPatternLocal(this);
91 ASSERT(m_Local);
92 AddPage(m_Local);
93}
94
95void CLogPattern::ExchangeData(CDataExchange *pDX,UINT from,UINT to)
96{
97 if(pDX->m_bSaveAndValidate){
98 for(UINT f=from;f<=to;f++){
99 for(UINT p=0;p<CSyslogSocket::totalPriorities;p++){
100 switch(pDX->m_pDlgWnd->IsDlgButtonChecked(m_ID[f][p])){
101 case 0:
102 m_Pattern[f][p]=FALSE;
103 break;
104 case 1:
105 m_Pattern[f][p]=TRUE;
106 break;
107 #ifndefNDEBUG
108 default:
109 ASSERT(FALSE);
110 break;
111#endif
112 }
113 }
114 }
115 }else{
116 for(UINT f=from;f<=to;f++){
117 for(UINT p=0;p<CSyslogSocket::totalPriorities;p++){
118 pDX->m_pDlgWnd->CheckDlgButton(m_ID[f][p],m_Pattern[f][p]?1:0);
119 }
120 }
121 }
122}
123
124void CLogPattern::PriorityOn(CWnd *pWnd,UINT pri,UINT from,UINT to)
125{
126 for(UINT f=from;f<=to;f++)
127 pWnd->CheckDlgButton(m_ID[f][pri],1);
128}
129
130void CLogPattern::PriorityXor(CWnd *pWnd,UINT pri,UINT from,UINT to)
131{
132 for(UINT f=from;f<=to;f++)
133 pWnd->CheckDlgButton(m_ID[f][pri],pWnd->IsDlgButtonChecked(m_ID[f][pri])?0:1);
134}
135
136void CLogPattern::FacilityOn(CWnd *pWnd,UINT fac)
137{
138 for(int p=0;p<CSyslogSocket::totalPriorities;p++)
139 pWnd->CheckDlgButton(m_ID[fac][p],1);
140}
141
142void CLogPattern::FacilityXor(CWnd *pWnd,UINT fac)
143{
144 for(int p=0;p<CSyslogSocket::totalPriorities;p++)
145 pWnd->CheckDlgButton(m_ID[fac][p],pWnd->IsDlgButtonChecked(m_ID[fac][p])?0:1);
146}
147
148void CLogPattern::AddTips(CToolTipCtrl& tt,CWnd *pWnd,UINT from,UINT to)
149{
150CString ttt;
151 for(UINT f=from;f<to;f++){
152 for(UINT p=0;p<CSyslogSocket::totalPriorities;p++){
153 ttt.Format("%s.%s",CSyslogSocket::m_Facilities[f],CSyslogSocket::m_Priorities[p]);
154 tt.AddTool(pWnd->GetDlgItem(m_ID[f][p]),ttt);
155 }
156 }
157}