Skip to content

Commit 0f86037

Browse files
committed
增加专门的日志目录, 所有内部日志与用户dump出的将都记录在这里.
1 parent 7d3870e commit 0f86037

File tree

9 files changed

+12
-10
lines changed

9 files changed

+12
-10
lines changed

logs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 日志文件夹
2+
3+
> 日志将会自动按照日期切割

lualib/Cache/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ local upper = string.upper
1717
local lower = string.lower
1818
local splite = string.gmatch
1919

20-
local Log = log:new()
20+
local Log = log:new({ dump = true, path = 'Cache'})
2121

2222
-- 注册命令
2323
local commands = {

lualib/DB/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local timer = require "internal.Timer"
33
local co = require "internal.Co"
44
local class = require "class"
55
local log = require "logging"
6-
local Log = log:new()
6+
local Log = log:new({ dump = true, path = 'DB'})
77

88
local co_self = co.self
99
local co_wait = co.wait

lualib/MQ/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local Timer = require "internal.Timer"
44
local mqtt = require "protocol.mqtt"
55
local redis = require "protocol.redis"
66

7-
local Log = log:new()
7+
local Log = log:new({ dump = true, path = 'MQ' })
88

99
local type = type
1010
local math = math

lualib/httpd/Router.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local log = require "logging"
2-
local Log = log:new()
2+
local Log = log:new({dump = true, path = 'httpd-Router'})
33

44
local math = math
55
local string = string

lualib/httpd/init.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,12 @@ end
140140
-- 记录日志到文件
141141
function httpd:log(path)
142142
if type(path) == 'string' and path ~= '' then
143-
self.logpath = path
144-
self.log = log:new({ path = self.logpath })
143+
self.log = log:new({ dump = true, path = path })
145144
end
146145
end
147146

148147
function httpd:tolog(code, path, ip, ip_list, method, speed)
149-
if self.logpath then
148+
if self.log then
150149
local log = fmt("[%s] - %s - %s - %s - %s - %d - req_time: %0.6f/Sec\n", os_date("%Y/%m/%d %H:%M:%S"), ip, ip_list, path, method, code, speed)
151150
self.log:dump(log)
152151
end

lualib/internal/Co.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local log = require "logging"
22
local task = require "task"
33

4-
local Log = log:new()
4+
local Log = log:new({ dump = true, path = 'internal-Co' })
55

66
local type = type
77
local assert = assert

lualib/internal/TCP.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local co = require "internal.Co"
44
local class = require "class"
55
local tcp = require "tcp"
66
local log = require "logging"
7-
local Log = log:new()
7+
local Log = log:new({ dump = true, path = 'internal-TCP' })
88

99
local split = string.sub
1010
local insert = table.insert

lualib/internal/Timer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local co = require "internal.Co"
22
local ti = require "timer"
33
local log = require "logging"
4-
local Log = log:new()
4+
local Log = log:new({ dump = true, path = 'internal-Timer' })
55

66
local type = type
77
local pcall = pcall

0 commit comments

Comments
 (0)