Skip to content

Commit aa4afdb

Browse files
coer-j-ayljupengfei
authored andcommitted
去掉vlog中的TAG
1 parent 1b046b4 commit aa4afdb

15 files changed

Lines changed: 78 additions & 141 deletions

File tree

config/server_cmds

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# remote_command local_command
22
# file subl
3+
4+
# default must
5+
explore xdg-open

config/server_dirs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/opt/jupengfei /home/ubuntu/compile
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# type1:type2:typ3... remote_command
2-
# txt:html:xml file
2+
txt:html:xml explore

core/rd.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local Log = require("log")
21
local Socket = require("lsocket")
32
local CMD_PDU = require("cmd_pdu")
43
local PDU = require("pdu")

core/rd_server.lua

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ local Log = require("log")
33
local PDU = require("pdu")
44
local CMD_PDU = require("cmd_pdu")
55

6-
local LOG_TAG = "rd_server"
7-
86
local function get_note_cus_cmd (suffix)
97
local cmd = nil
108

@@ -22,31 +20,7 @@ local function get_note_cus_cmd (suffix)
2220
end
2321

2422
local function get_note_sys_cmd (suffix)
25-
local file_type, file_cmd
26-
27-
local type_file = io.popen("assoc ." .. suffix, "r")
28-
if (type_file ~= nil) then
29-
local msg = type_file:read("*l")
30-
31-
file_type = msg and string.match(msg, "=%a+")
32-
type_file:close()
33-
end
34-
35-
if (file_type ~= nil) then
36-
local cmd_file = io.popen("ftype " .. string.sub(file_type, 2), "r")
37-
if (cmd_file ~= nil) then
38-
local msg = cmd_file:read("*l")
39-
40-
file_cmd = msg and string.match(msg, "=%a+")
41-
cmd_file:close()
42-
end
43-
end
44-
45-
if (file_cmd ~= nil) then
46-
return string.sub(file_cmd, 2)
47-
else
48-
return nil
49-
end
23+
return nil
5024
end
5125

5226
local custom_remote_command = {
@@ -71,17 +45,18 @@ local custom_remote_command = {
7145
}
7246

7347
local function get_mapped_cmd (cmd, cmd_args, cmd_path)
74-
local remote_cmd = cmd
48+
local remote_cmd = nil
7549

7650
if (custom_remote_command[cmd] ~= nil) then
7751
remote_cmd = custom_remote_command[cmd](cmd, cmd_args, cmd_path)
78-
else
79-
for cmd, cmd_proc in pairs(server_cfg.remote_cmd_map) do
80-
if (remote_cmd == cmd) then
81-
remote_cmd = cmd_proc
82-
break
83-
end
84-
end
52+
end
53+
54+
if remote_cmd == nil then
55+
remote_cmd = server_cfg.remote_cmd_map[cmd]
56+
end
57+
58+
if remote_cmd == nil then
59+
remote_cmd = cmd
8560
end
8661

8762
return remote_cmd
@@ -108,11 +83,7 @@ local function get_local_command (cmd, cmd_args, cmd_path)
10883

10984
cmd_args = string.gsub(cmd_args, "\\", "/")
11085
cmd_path = string.gsub(cmd_path, "\\", "/")
111-
ext_command = " & "
112-
113-
target_cmd = server_cfg.remote_cmd_map[cmd]
114-
target_cmd = target_cmd or cmd
115-
target_cmd = target_cmd.." "..cmd_args
86+
target_cmd = cmd.." "..cmd_args
11687

11788
if (cmd_path and #cmd_path > 0) then
11889
target_cmd = "cd "..cmd_path..";"..target_cmd.." & "
@@ -159,7 +130,7 @@ local function handle_client (socket)
159130
end
160131
end
161132
else
162-
Log.e(LOG_TAG, "rd_server receive illegal message")
133+
Log.e("rd_server receive illegal message")
163134
end
164135
end
165136

@@ -169,7 +140,7 @@ dofile(cur_path .. "/core/config.lua")
169140

170141
local server_socket = Socket.server(GLOBAL_CONFIG.server_ip, GLOBAL_CONFIG.server_port)
171142
if (server_socket == nil) then
172-
Log.e(LOG_TAG, "rd_server create failed")
143+
Log.e("rd_server create failed")
173144
return
174145
end
175146

core/server_params.lua

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ local function parse_server (path)
44

55
local line = f:read("*line")
66
while line ~= nil do
7-
local temp = {}
8-
string.gsub(line, "[^ ]+", function (w)
9-
table.insert(temp, w)
10-
end)
7+
local temp = {}
8+
9+
for w in string.gmatch(line, "%g+") do
10+
table.insert(temp, w)
11+
end
12+
13+
if #temp >= 2 and temp[1] ~= "#" then
14+
result[temp[1]] = temp[2]
15+
end
1116

12-
result[tmep[0]] = temp[1]
1317
line = f:read("*line")
1418
end
1519

@@ -22,8 +26,8 @@ local cmds = cur_path .. "/config/server_cmds"
2226
local maps = cur_path .. "/config/server_maps"
2327

2428
server_cfg = {
25-
["remote_cmd_map"] = parse_server(cmds), -- offer avalable commands
26-
["share_directory_map"] = parse_server(dirs), -- map remoteDir to LocalDir
29+
["remote_cmd_map"] = parse_server(cmds), -- offer avalable commands
30+
["share_directory_map"] = parse_server(dirs), -- map remoteDir to LocalDir
2731
}
2832

2933
local function parse_file_type (path)
@@ -33,9 +37,9 @@ local function parse_file_type (path)
3337

3438
for k, v in pairs(map) do
3539
result[k] = remote_cmds[v]
36-
do
40+
end
3741

3842
return result
3943
end
4044

41-
server_cfg["file_type_map"] = parse_file_type(maps) -- map fileType to Commands
45+
server_cfg["file_type_map"] = parse_file_type(maps) -- map fileType to Commands

lib/liblog.so

-48 Bytes
Binary file not shown.

lib/libsocket.so

-144 Bytes
Binary file not shown.

lib/libutil.so

-56 Bytes
Binary file not shown.

module/log.lua

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@
1818

1919
local vlog = require("liblog")
2020

21-
local function log_detail (tag, level, msg)
21+
local function log_detail (level, msg)
2222
local msg = level .. " " .. msg
23-
vlog.log (tag, msg)
23+
vlog.log (msg)
2424
end
2525

2626
local Log = {}
27-
function Log.d (tag, msg)
28-
log_detail (tag, "DEBUG", msg)
27+
function Log.d (msg)
28+
log_detail ("DEBUG", msg)
2929
end
3030

31-
function Log.i (tag, msg)
32-
log_detail (tag, "INFO", msg)
31+
function Log.i (msg)
32+
log_detail ("INFO", msg)
3333
end
3434

35-
function Log.e (tag, msg)
36-
log_detail (tag, "ERROR", msg)
35+
function Log.e (msg)
36+
log_detail ("ERROR", msg)
3737
end
3838

39-
function Log.v (tag, msg)
40-
log_detail (tag, "VERBOSE", msg)
39+
function Log.v (msg)
40+
log_detail ("VERBOSE", msg)
4141
end
4242

43-
return Log
43+
return Log

0 commit comments

Comments
 (0)