Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
Bailun.DataCenter
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangwanchang
Bailun.DataCenter
Commits
096e3a5e
Commit
096e3a5e
authored
May 08, 2018
by
wangwanchang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parent
76594b07
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
1 deletion
+139
-1
.gitignore
.gitignore
+1
-1
LogEntity.cs
trunk/Bailun.Util.Extension/Domain/Log/LogEntity.cs
+52
-0
LogManager.cs
trunk/Bailun.Util.Extension/Domain/Log/LogManager.cs
+76
-0
LogLevel.cs
trunk/Bailun.Util/Log/LogLevel.cs
+10
-0
No files found.
.gitignore
View file @
096e3a5e
...
@@ -22,7 +22,7 @@ x86/
...
@@ -22,7 +22,7 @@ x86/
bld/
bld/
[Bb]in/
[Bb]in/
[Oo]bj/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
# Visual Studio 2015/2017 cache/options directory
.vs/
.vs/
...
...
trunk/Bailun.Util.Extension/Domain/Log/LogEntity.cs
0 → 100644
View file @
096e3a5e
using
System
;
using
Abp.Domain.Entities
;
using
Bailun.Util.Log
;
namespace
Bailun.Util.Extension.Domain.Log
{
/// <summary>
/// 版 本
/// Copyright (c) 2013-2016 广州百伦供应链科技有限公司
/// 创 建:zhangpan
/// 日 期:2017-08-28 11:11
/// 描 述:日志信息
/// </summary>
public
class
LogEntity
:
Entity
<
long
>
{
#
region
实体成员
/// <summary>
/// 名称
/// </summary>
/// <returns></returns>
public
string
InterfaceName
{
get
;
set
;
}
/// <summary>
/// 创建时间
/// </summary>
/// <returns></returns>
public
DateTime
?
CreateTime
{
get
;
set
;
}
/// <summary>
/// 消息
/// </summary>
/// <returns></returns>
public
string
Info
{
get
;
set
;
}
/// <summary>
/// 类型
/// </summary>
/// <returns></returns>
public
LogLevel
LogLevel
{
get
;
set
;
}
/// <summary>
/// 参数
/// </summary>
/// <returns></returns>
public
string
Data
{
get
;
set
;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public
string
RequestUrl
{
get
;
set
;
}
#
endregion
}
}
\ No newline at end of file
trunk/Bailun.Util.Extension/Domain/Log/LogManager.cs
0 → 100644
View file @
096e3a5e
using
System
;
using
Abp.Timing
;
using
Bailun.Util
;
using
Bailun.Util.Email
;
using
Bailun.Util.Log
;
namespace
Bailun.Util.Extension.Domain.Log
{
public
static
class
LogManager
{
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="name"></param>
/// <param name="exception"></param>
/// <param name="logLevel"></param>
/// <param name="isAlarm">是否邮件报警提醒</param>
/// <returns></returns>
public
static
T
Create
<
T
>(
string
name
,
Exception
exception
,
LogLevel
logLevel
,
bool
isAlarm
)
where
T
:
LogEntity
,
new
()
{
var
log
=
new
T
()
{
InterfaceName
=
name
,
CreateTime
=
Clock
.
Now
,
Data
=
exception
?.
Source
,
LogLevel
=
logLevel
,
RequestUrl
=
exception
?.
HelpLink
};
if
(
exception
!=
null
)
{
var
msg
=
new
{
Message
=
exception
.
Message
,
Target
=
exception
.
TargetSite
,
StackTrace
=
exception
.
StackTrace
,
InnerException
=
$"
{
exception
.
InnerException
?.
Message
}
;
{
exception
.
InnerException
?.
InnerException
?.
Message
}
;"
}.
ToJson
();
log
.
Info
=
msg
;
}
if
(
isAlarm
&&
logLevel
==
LogLevel
.
Error
)
{
EmailManager
.
SendErrorAlarm
(
name
,
$"方法名:
{
log
.
InterfaceName
}
,
{
log
.
Info
}
"
);
}
return
log
;
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="name"></param>
/// <param name="message"></param>
/// <param name="data"></param>
/// <param name="logLevel"></param>
/// <param name="url"></param>
/// <param name="isAlarm">是否邮件报警提醒</param>
/// <returns></returns>
public
static
T
Create
<
T
>(
string
name
,
string
message
,
object
data
,
LogLevel
logLevel
,
string
url
,
bool
isAlarm
)
where
T
:
LogEntity
,
new
()
{
var
log
=
new
T
()
{
InterfaceName
=
name
,
CreateTime
=
Clock
.
Now
,
Data
=
data
?.
ToJson
(),
LogLevel
=
logLevel
,
Info
=
message
};
if
(
isAlarm
&&
logLevel
==
LogLevel
.
Error
)
{
EmailManager
.
SendErrorAlarm
(
name
,
$"方法名:
{
log
.
InterfaceName
}
,
{
log
.
Info
}
"
);
}
return
log
;
}
}
}
\ No newline at end of file
trunk/Bailun.Util/Log/LogLevel.cs
0 → 100644
View file @
096e3a5e
namespace
Bailun.Util.Log
{
public
enum
LogLevel
{
Info
=
1
,
Warn
=
2
,
Error
=
3
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment