Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC1250-ACPackingStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 73363f32
由
LN
编写于
2020-01-03 18:53:17 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
日志修改
1 个父辈
150c5755
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
51 行增加
和
77 行删除
source/ACPackingStore/FrmStore.cs
source/Common/util/LogUtil.cs
source/ACPackingStore/FrmStore.cs
查看文件 @
73363f3
...
@@ -265,7 +265,7 @@ namespace OnlineStore.ACPackingStore
...
@@ -265,7 +265,7 @@ namespace OnlineStore.ACPackingStore
}
}
private
void
btnClearLog_Click
(
object
sender
,
EventArgs
e
)
private
void
btnClearLog_Click
(
object
sender
,
EventArgs
e
)
{
{
logBox
.
Clear
();
LogUtil
.
ClearLog
();
}
}
private
void
debug_enable_checkBox_CheckedChanged
(
object
sender
,
EventArgs
e
)
private
void
debug_enable_checkBox_CheckedChanged
(
object
sender
,
EventArgs
e
)
...
...
source/Common/util/LogUtil.cs
查看文件 @
73363f3
...
@@ -13,7 +13,7 @@ namespace OnlineStore.Common
...
@@ -13,7 +13,7 @@ namespace OnlineStore.Common
{
{
public
static
readonly
ILog
AIOLog
=
LogManager
.
GetLogger
(
"AIOBOXLog"
);
public
static
readonly
ILog
AIOLog
=
LogManager
.
GetLogger
(
"AIOBOXLog"
);
private
static
LogUtil
instance
=
new
LogUtil
();
private
static
LogUtil
instance
=
new
LogUtil
();
public
delegate
void
ShowLog
(
string
msg
,
Color
color
);
public
delegate
void
ShowLog
(
string
msg
,
Color
color
);
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
MethodBase
.
GetCurrentMethod
().
DeclaringType
);
public
static
Dictionary
<
int
,
DateTime
>
lastErrorLogTime
=
new
Dictionary
<
int
,
DateTime
>();
public
static
Dictionary
<
int
,
DateTime
>
lastErrorLogTime
=
new
Dictionary
<
int
,
DateTime
>();
...
@@ -24,60 +24,36 @@ namespace OnlineStore.Common
...
@@ -24,60 +24,36 @@ namespace OnlineStore.Common
public
static
bool
debug_opened
=
false
;
public
static
bool
debug_opened
=
false
;
public
static
void
info
(
ILog
log
,
string
msg
)
{
if
(
log
==
null
)
{
return
;
}
log
.
Info
(
" - "
+
msg
);
public
static
void
info
(
ILog
log
,
string
msg
)
if
(
logBox
==
null
)
{
{
log
.
Info
(
" - "
+
msg
);
return
;
}
AddToBox
(
msg
,
Color
.
Black
);
AddToBox
(
msg
,
Color
.
Black
);
//clear();
}
}
public
static
void
info
(
ILog
log
,
string
msg
,
Color
color
)
public
static
void
info
(
ILog
log
,
string
msg
,
Color
color
)
{
{
log
.
Info
(
" - "
+
msg
);
log
.
Info
(
" - "
+
msg
);
if
(
logBox
==
null
)
AddToBox
(
msg
,
color
);
{
return
;
}
AddToBox
(
msg
,
color
);
}
}
public
static
void
debug
(
ILog
log
,
string
msg
,
Color
color
)
public
static
void
debug
(
ILog
log
,
string
msg
,
Color
color
)
{
{
log
.
Debug
(
" - "
+
msg
);
log
.
Debug
(
" - "
+
msg
);
if
(
debug_opened
)
if
(
debug_opened
)
{
{
if
(
logBox
==
null
)
{
return
;
}
AddToBox
(
msg
,
color
);
AddToBox
(
msg
,
color
);
}
}
}
}
public
static
void
debug
(
ILog
log
,
string
msg
)
public
static
void
debug
(
ILog
log
,
string
msg
)
{
{
log
.
Debug
(
" - "
+
msg
);
log
.
Debug
(
" - "
+
msg
);
if
(
debug_opened
)
if
(
debug_opened
)
{
{
if
(
logBox
==
null
)
AddToBox
(
msg
,
Color
.
Gray
);
{
return
;
}
AddToBox
(
msg
,
Color
.
Gray
);
}
}
}
}
private
static
List
<
string
>
lasErrorLogList
=
new
List
<
string
>();
private
static
int
errCount
=
5
;
public
static
void
error
(
string
errorMsg
,
int
type
,
int
spanSeconds
=
10
)
private
static
List
<
string
>
lasErrorLogList
=
new
List
<
string
>();
public
static
void
error
(
string
errorMsg
,
int
type
,
int
spanSeconds
=
10
)
{
{
if
(
lastErrorLogTime
.
ContainsKey
(
type
))
if
(
lastErrorLogTime
.
ContainsKey
(
type
))
{
{
...
@@ -101,76 +77,74 @@ namespace OnlineStore.Common
...
@@ -101,76 +77,74 @@ namespace OnlineStore.Common
}
}
public
static
void
error
(
ILog
log
,
string
errorMsg
)
public
static
void
error
(
ILog
log
,
string
errorMsg
)
{
{
//if (!lasErrorLogList.Contains(errorMsg))
log
.
Error
(
" - "
+
errorMsg
);
{
AddToBox
(
errorMsg
,
Color
.
Red
);
log
.
Error
(
" - "
+
errorMsg
);
if
(
logBox
==
null
)
{
return
;
}
AddToBox
(
errorMsg
,
Color
.
Red
);
}
//lasErrorLogList.Add(errorMsg);
//if (lasErrorLogList.Count > errCount)
//{
// lasErrorLogList.RemoveAt(0);
//}
}
}
private
static
void
AddToBox
(
string
msg
,
Color
color
)
private
static
void
AddToBox
(
string
msg
,
Color
color
)
{
{
try
try
{
{
ShowLogPro
(
msg
,
color
);
ShowLogPro
(
msg
,
color
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
Error
(
"出错:"
+
ex
.
StackTrace
);
LOGGER
.
Error
(
"出错:"
+
ex
.
StackTrace
);
}
}
}
}
private
static
int
count
=
0
;
private
static
List
<
string
>
logList
=
new
List
<
string
>()
;
private
static
void
ShowLogPro
(
string
msg
,
Color
color
)
private
static
void
ShowLogPro
(
string
msg
,
Color
color
)
{
{
try
try
{
{
//clear();
if
(
count
>
showCount
)
if
(
logList
.
Count
>
0
)
{
{
count
=
0
;
logList
.
RemoveAt
(
0
);
logBox
.
Clear
();
}
}
//logBox.SelectionColor = color;
if
(
logList
.
Count
>=
showCount
)
{
logList
.
RemoveAt
(
logList
.
Count
-
1
);
}
System
.
DateTime
now
=
System
.
DateTime
.
Now
;
System
.
DateTime
now
=
System
.
DateTime
.
Now
;
logBox
.
AppendText
(
now
.
ToLongTimeString
()
+
" "
+
msg
+
Environment
.
NewLine
);
logList
.
Insert
(
0
,
now
.
ToLongTimeString
()
+
" "
+
msg
+
Environment
.
NewLine
);
count
++;
logList
.
Insert
(
0
,
Environment
.
NewLine
);
string
text
=
""
;
foreach
(
string
str
in
logList
)
{
text
+=
str
;
}
if
(
logBox
==
null
)
{
return
;
}
logBox
.
Text
=
text
;
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LOGGER
.
Error
(
"出错:"
+
ex
.
ToString
());
LOGGER
.
Error
(
"出错:"
+
ex
.
ToString
());
}
}
}
}
public
static
void
debug
(
string
msg
)
{
debug
(
LOGGER
,
msg
);
}
public
static
void
error
(
string
errorMsg
)
{
error
(
LOGGER
,
errorMsg
);
}
public
static
void
ClearLog
()
public
static
void
ClearLog
()
{
{
if
(
logBox
!=
null
)
if
(
logBox
!=
null
)
{
{
logList
.
Clear
();
logBox
.
Text
=
""
;
logBox
.
Text
=
""
;
count
=
0
;
}
}
}
}
public
static
void
info
(
string
msg
)
public
static
void
debug
(
string
msg
)
{
debug
(
LOGGER
,
msg
);
}
public
static
void
error
(
string
errorMsg
)
{
{
info
(
LOGGER
,
msg
);
error
(
LOGGER
,
errorMsg
);
}
}
public
static
void
info
(
string
msg
)
{
info
(
LOGGER
,
msg
);
}
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论