Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
老鱼er
et
提交
99a0005e
E
et
项目概览
老鱼er
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
et
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
99a0005e
编写于
10月 23, 2016
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
根据不同的AppType和AppId,log打印到不同的文件中
上级
c217daa9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
45 addition
and
22 deletion
+45
-22
Server/App/NLog.config
Server/App/NLog.config
+6
-4
Server/App/Program.cs
Server/App/Program.cs
+6
-3
Server/App/Server.App.csproj
Server/App/Server.App.csproj
+4
-0
Server/Base/Log.cs
Server/Base/Log.cs
+1
-1
Server/Model/Component/AppManagerComponent.cs
Server/Model/Component/AppManagerComponent.cs
+19
-12
Unity/Assets/Plugins/Base/Network/TNet/TSocket.cs
Unity/Assets/Plugins/Base/Network/TNet/TSocket.cs
+9
-2
未找到文件。
Server/App/NLog.config
浏览文件 @
99a0005e
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
nlog
xmlns
=
"http://www.nlog-project.org/schemas/NLog.xsd"
xmlns
:
xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
>
<
variable
name
=
"appType"
value
=
""
/>
<
variable
name
=
"appId"
value
=
""
/>
<
targets
>
<
target
name
=
"debug"
xsi
:
type
=
"File"
fileName
=
"${basedir}/Log
.
Debug.txt"
fileName
=
"${basedir}/Log
s/Log-${var:appType}-${var:appId}-
Debug.txt"
deleteOldFileOnStartup
=
"true"
layout
=
"${longdate} ${
threadid:padCharacter=0:padding=4:fixedLength=true
} ${message}"
/>
layout
=
"${longdate} ${
var:appType} ${var:appId
} ${message}"
/>
</
targets
>
<
targets
>
<
target
name
=
"error"
xsi
:
type
=
"File"
fileName
=
"${basedir}/Log
.
Error.txt"
fileName
=
"${basedir}/Log
s/Log-${var:appType}-${var:appId}-
Error.txt"
deleteOldFileOnStartup
=
"false"
layout
=
"${longdate} ${
threadid:padCharacter=0:padding=4:fixedLength=true
} ${message}"
/>
layout
=
"${longdate} ${
var:appType} ${var:appId
} ${message}"
/>
</
targets
>
<
rules
>
<
logger
name
=
"*"
minlevel
=
"Debug"
writeTo
=
"debug"
/>
...
...
Server/App/Program.cs
浏览文件 @
99a0005e
using
System
;
using
Base
;
using
Model
;
using
NLog
;
using
Object
=
Base
.
Object
;
namespace
App
...
...
@@ -11,8 +12,6 @@ namespace App
{
try
{
Log
.
Info
(
"server start........................"
);
BsonClassMapRegister
.
Register
();
Object
.
ObjectManager
.
Register
(
"Base"
,
typeof
(
Game
).
Assembly
);
...
...
@@ -20,7 +19,11 @@ namespace App
Object
.
ObjectManager
.
Register
(
"Controller"
,
DllHelper
.
GetController
());
StartConfig
startConfig
=
Game
.
Scene
.
AddComponent
<
StartConfigComponent
,
string
[
]>
(
args
).
MyConfig
;
LogManager
.
Configuration
.
Variables
[
"appType"
]
=
startConfig
.
Options
.
AppType
;
LogManager
.
Configuration
.
Variables
[
"appId"
]
=
startConfig
.
Options
.
Id
.
ToString
(
"D4"
);
Log
.
Info
(
"server start........................"
);
Game
.
Scene
.
AddComponent
<
EventComponent
>();
Game
.
Scene
.
AddComponent
<
TimerComponent
>();
...
...
Server/App/Server.App.csproj
浏览文件 @
99a0005e
...
...
@@ -37,6 +37,10 @@
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\Lib\MongoDB.Bson.dll
</HintPath>
</Reference>
<Reference
Include=
"NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"
>
<SpecificVersion>
False
</SpecificVersion>
<HintPath>
..\Lib\NLog.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
</ItemGroup>
...
...
Server/Base/Log.cs
浏览文件 @
99a0005e
...
...
@@ -5,7 +5,7 @@ namespace Base
{
public
static
class
Log
{
private
static
readonly
ILog
globalLog
=
new
NLogAdapter
(
new
StackInfoDecorater
()
);
private
static
readonly
ILog
globalLog
=
new
NLogAdapter
();
public
static
Dictionary
<
long
,
Action
<
LogType
,
string
>>
Callback
{
get
;
}
=
new
Dictionary
<
long
,
Action
<
LogType
,
string
>>();
...
...
Server/Model/Component/AppManagerComponent.cs
浏览文件 @
99a0005e
using
System.Collections.Generic
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
...
...
@@ -37,7 +38,7 @@ namespace Model
#if __MonoCS__
const
string
exe
=
@"mono"
;
const
string
exe
=
@"
/usr/local/bin/
mono"
;
string
arguments
=
$"App.exe --id=
{
startConfig
.
Options
.
Id
}
--appType=
{
startConfig
.
Options
.
AppType
}
"
;
const
string
workDir
=
@"../Server/Bin/Debug"
;
#else
...
...
@@ -45,18 +46,24 @@ namespace Model
string
arguments
=
$"--id=
{
startConfig
.
Options
.
Id
}
--appType=
{
startConfig
.
Options
.
AppType
}
"
;
const
string
workDir
=
@"..\Server\Bin\Debug"
;
#endif
Log
.
Debug
(
$"
{
startConfig
.
Options
.
Id
}
{
MongoHelper
.
ToJson
(
startConfig
)}
"
);
ProcessStartInfo
info
=
new
ProcessStartInfo
try
{
FileName
=
exe
,
Arguments
=
arguments
,
CreateNoWindow
=
true
,
UseShellExecute
=
true
,
WorkingDirectory
=
workDir
};
ProcessStartInfo
info
=
new
ProcessStartInfo
{
FileName
=
exe
,
Arguments
=
arguments
,
CreateNoWindow
=
true
,
UseShellExecute
=
true
,
WorkingDirectory
=
workDir
};
Process
process
=
Process
.
Start
(
info
);
this
.
processes
.
Add
(
process
.
Id
,
process
);
Process
process
=
Process
.
Start
(
info
);
this
.
processes
.
Add
(
process
.
Id
,
process
);
}
catch
(
Exception
e
)
{
Log
.
Error
(
e
.
ToString
());
}
}
}
}
...
...
Unity/Assets/Plugins/Base/Network/TNet/TSocket.cs
浏览文件 @
99a0005e
...
...
@@ -30,8 +30,15 @@ namespace Base
public
TSocket
(
TPoller
poller
,
string
host
,
int
port
):
this
(
poller
)
{
this
.
Bind
(
host
,
port
);
this
.
Listen
(
100
);
try
{
this
.
Bind
(
host
,
port
);
this
.
Listen
(
100
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
$"socket bind error:
{
host
}
{
port
}
"
,
e
);
}
}
public
Socket
Socket
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录