Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
07903b0a
authored
Aug 15, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: improve logging for channel operations with detailed context
parent
9da13fda
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
model/channel.go
+13
-13
No files found.
model/channel.go
View file @
07903b0a
...
...
@@ -209,7 +209,7 @@ func (channel *Channel) GetOtherInfo() map[string]interface{} {
if
channel
.
OtherInfo
!=
""
{
err
:=
common
.
Unmarshal
([]
byte
(
channel
.
OtherInfo
),
&
otherInfo
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to unmarshal other info: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to unmarshal other info: channel_id=%d, tag=%s, name=%s, error=%v"
,
channel
.
Id
,
channel
.
GetTag
(),
channel
.
Name
,
err
))
}
}
return
otherInfo
...
...
@@ -218,7 +218,7 @@ func (channel *Channel) GetOtherInfo() map[string]interface{} {
func
(
channel
*
Channel
)
SetOtherInfo
(
otherInfo
map
[
string
]
interface
{})
{
otherInfoBytes
,
err
:=
json
.
Marshal
(
otherInfo
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to marshal other info: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to marshal other info: channel_id=%d, tag=%s, name=%s, error=%v"
,
channel
.
Id
,
channel
.
GetTag
(),
channel
.
Name
,
err
))
return
}
channel
.
OtherInfo
=
string
(
otherInfoBytes
)
...
...
@@ -492,7 +492,7 @@ func (channel *Channel) UpdateResponseTime(responseTime int64) {
ResponseTime
:
int
(
responseTime
),
})
.
Error
if
err
!=
nil
{
common
.
SysLog
(
"failed to update response time: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to update response time: channel_id=%d, error=%v"
,
channel
.
Id
,
err
))
}
}
...
...
@@ -502,7 +502,7 @@ func (channel *Channel) UpdateBalance(balance float64) {
Balance
:
balance
,
})
.
Error
if
err
!=
nil
{
common
.
SysLog
(
"failed to update balance: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to update balance: channel_id=%d, error=%v"
,
channel
.
Id
,
err
))
}
}
...
...
@@ -618,7 +618,7 @@ func UpdateChannelStatus(channelId int, usingKey string, status int, reason stri
if
shouldUpdateAbilities
{
err
:=
UpdateAbilityStatus
(
channelId
,
status
==
common
.
ChannelStatusEnabled
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to update ability status: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to update ability status: channel_id=%d, error=%v"
,
channelId
,
err
))
}
}
}()
...
...
@@ -646,7 +646,7 @@ func UpdateChannelStatus(channelId int, usingKey string, status int, reason stri
}
err
=
channel
.
Save
()
if
err
!=
nil
{
common
.
SysLog
(
"failed to update channel status: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to update channel status: channel_id=%d, status=%d, error=%v"
,
channel
.
Id
,
status
,
err
))
return
false
}
}
...
...
@@ -708,7 +708,7 @@ func EditChannelByTag(tag string, newTag *string, modelMapping *string, models *
for
_
,
channel
:=
range
channels
{
err
=
channel
.
UpdateAbilities
(
nil
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to update abilities: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to update abilities: channel_id=%d, tag=%s, error=%v"
,
channel
.
Id
,
channel
.
GetTag
(),
err
))
}
}
}
...
...
@@ -732,7 +732,7 @@ func UpdateChannelUsedQuota(id int, quota int) {
func
updateChannelUsedQuota
(
id
int
,
quota
int
)
{
err
:=
DB
.
Model
(
&
Channel
{})
.
Where
(
"id = ?"
,
id
)
.
Update
(
"used_quota"
,
gorm
.
Expr
(
"used_quota + ?"
,
quota
))
.
Error
if
err
!=
nil
{
common
.
SysLog
(
"failed to update channel used quota: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to update channel used quota: channel_id=%d, delta_quota=%d, error=%v"
,
id
,
quota
,
err
))
}
}
...
...
@@ -825,7 +825,7 @@ func (channel *Channel) GetSetting() dto.ChannelSettings {
if
channel
.
Setting
!=
nil
&&
*
channel
.
Setting
!=
""
{
err
:=
common
.
Unmarshal
([]
byte
(
*
channel
.
Setting
),
&
setting
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to unmarshal setting: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to unmarshal setting: channel_id=%d, error=%v"
,
channel
.
Id
,
err
))
channel
.
Setting
=
nil
// 清空设置以避免后续错误
_
=
channel
.
Save
()
// 保存修改
}
...
...
@@ -836,7 +836,7 @@ func (channel *Channel) GetSetting() dto.ChannelSettings {
func
(
channel
*
Channel
)
SetSetting
(
setting
dto
.
ChannelSettings
)
{
settingBytes
,
err
:=
common
.
Marshal
(
setting
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to marshal setting: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to marshal setting: channel_id=%d, error=%v"
,
channel
.
Id
,
err
))
return
}
channel
.
Setting
=
common
.
GetPointer
[
string
](
string
(
settingBytes
))
...
...
@@ -847,7 +847,7 @@ func (channel *Channel) GetOtherSettings() dto.ChannelOtherSettings {
if
channel
.
OtherSettings
!=
""
{
err
:=
common
.
UnmarshalJsonStr
(
channel
.
OtherSettings
,
&
setting
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to unmarshal setting: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to unmarshal setting: channel_id=%d, error=%v"
,
channel
.
Id
,
err
))
channel
.
OtherSettings
=
"{}"
// 清空设置以避免后续错误
_
=
channel
.
Save
()
// 保存修改
}
...
...
@@ -858,7 +858,7 @@ func (channel *Channel) GetOtherSettings() dto.ChannelOtherSettings {
func
(
channel
*
Channel
)
SetOtherSettings
(
setting
dto
.
ChannelOtherSettings
)
{
settingBytes
,
err
:=
common
.
Marshal
(
setting
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to marshal setting: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to marshal setting: channel_id=%d, error=%v"
,
channel
.
Id
,
err
))
return
}
channel
.
OtherSettings
=
string
(
settingBytes
)
...
...
@@ -869,7 +869,7 @@ func (channel *Channel) GetParamOverride() map[string]interface{} {
if
channel
.
ParamOverride
!=
nil
&&
*
channel
.
ParamOverride
!=
""
{
err
:=
common
.
Unmarshal
([]
byte
(
*
channel
.
ParamOverride
),
&
paramOverride
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to unmarshal param override: "
+
err
.
Error
(
))
common
.
SysLog
(
fmt
.
Sprintf
(
"failed to unmarshal param override: channel_id=%d, error=%v"
,
channel
.
Id
,
err
))
}
}
return
paramOverride
...
...
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