mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	服务访问日志增加今天和历史的访问日志查看
This commit is contained in:
		@@ -110,7 +110,7 @@ func (this *HTTPAccessLogDAO) CreateHTTPAccessLogsWithDAO(daoWrapper *HTTPAccess
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 读取往前的 单页访问日志
 | 
			
		||||
func (this *HTTPAccessLogDAO) ListAccessLogs(lastRequestId string, size int64, day string, serverId int64, reverse bool) (result []*HTTPAccessLog, nextLastRequestId string, hasMore bool, err error) {
 | 
			
		||||
func (this *HTTPAccessLogDAO) ListAccessLogs(lastRequestId string, size int64, day string, serverId int64, reverse bool, hasError bool) (result []*HTTPAccessLog, nextLastRequestId string, hasMore bool, err error) {
 | 
			
		||||
	if len(day) != 8 {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
@@ -120,18 +120,18 @@ func (this *HTTPAccessLogDAO) ListAccessLogs(lastRequestId string, size int64, d
 | 
			
		||||
		size = 1000
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	result, nextLastRequestId, err = this.listAccessLogs(lastRequestId, size, day, serverId, reverse)
 | 
			
		||||
	result, nextLastRequestId, err = this.listAccessLogs(lastRequestId, size, day, serverId, reverse, hasError)
 | 
			
		||||
	if err != nil || int64(len(result)) < size {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	moreResult, _, _ := this.listAccessLogs(nextLastRequestId, 1, day, serverId, reverse)
 | 
			
		||||
	moreResult, _, _ := this.listAccessLogs(nextLastRequestId, 1, day, serverId, reverse, hasError)
 | 
			
		||||
	hasMore = len(moreResult) > 0
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 读取往前的单页访问日志
 | 
			
		||||
func (this *HTTPAccessLogDAO) listAccessLogs(lastRequestId string, size int64, day string, serverId int64, reverse bool) (result []*HTTPAccessLog, nextLastRequestId string, err error) {
 | 
			
		||||
func (this *HTTPAccessLogDAO) listAccessLogs(lastRequestId string, size int64, day string, serverId int64, reverse bool, hasError bool) (result []*HTTPAccessLog, nextLastRequestId string, err error) {
 | 
			
		||||
	if size <= 0 {
 | 
			
		||||
		return nil, lastRequestId, nil
 | 
			
		||||
	}
 | 
			
		||||
@@ -177,6 +177,9 @@ func (this *HTTPAccessLogDAO) listAccessLogs(lastRequestId string, size int64, d
 | 
			
		||||
			if serverId > 0 {
 | 
			
		||||
				query.Attr("serverId", serverId)
 | 
			
		||||
			}
 | 
			
		||||
			if hasError {
 | 
			
		||||
				query.Where("status>400")
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// offset
 | 
			
		||||
			if len(lastRequestId) > 0 {
 | 
			
		||||
 
 | 
			
		||||
@@ -491,7 +491,7 @@ func (this *NodeDAO) ComposeNodeConfig(nodeId int64) (*nodeconfigs.NodeConfig, e
 | 
			
		||||
 | 
			
		||||
	// 全局设置
 | 
			
		||||
	// TODO 根据用户的不同读取不同的全局设置
 | 
			
		||||
	settingJSON, err := SharedSysSettingDAO.ReadSetting(SettingCodeGlobalConfig)
 | 
			
		||||
	settingJSON, err := SharedSysSettingDAO.ReadSetting(SettingCodeServerGlobalConfig)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,9 @@ type SysSettingDAO dbs.DAO
 | 
			
		||||
type SettingCode = string
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	SettingCodeGlobalConfig SettingCode = "globalConfig"
 | 
			
		||||
	SettingCodeServerGlobalConfig SettingCode = "serverGlobalConfig" // 服务相关全局设置
 | 
			
		||||
	SettingCodeNodeMonitor        SettingCode = "nodeMonitor"        // 监控节点状态
 | 
			
		||||
	SettingCodeClusterHealthCheck SettingCode = "clusterHealthCheck" // 集群健康检查
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func NewSysSettingDAO() *SysSettingDAO {
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ func (this *HTTPAccessLogService) ListHTTPAccessLogs(ctx context.Context, req *p
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	accessLogs, requestId, hasMore, err := models.SharedHTTPAccessLogDAO.ListAccessLogs(req.RequestId, req.Size, req.Day, req.ServerId, req.Reverse)
 | 
			
		||||
	accessLogs, requestId, hasMore, err := models.SharedHTTPAccessLogDAO.ListAccessLogs(req.RequestId, req.Size, req.Day, req.ServerId, req.Reverse, req.HasError)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -87,7 +87,7 @@ func (this *HealthCheckClusterTask) Stop() {
 | 
			
		||||
// 单个循环任务
 | 
			
		||||
func (this *HealthCheckClusterTask) loop(seconds int64) error {
 | 
			
		||||
	// 检查上次运行时间,防止重复运行
 | 
			
		||||
	settingKey := "cluster_health_check_%d" + numberutils.FormatInt64(this.clusterId)
 | 
			
		||||
	settingKey := models.SettingCodeClusterHealthCheck + numberutils.FormatInt64(this.clusterId)
 | 
			
		||||
	timestamp := time.Now().Unix()
 | 
			
		||||
	c, err := models.SharedSysSettingDAO.CompareInt64Setting(settingKey, timestamp-seconds)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ func (this *NodeMonitorTask) Run() {
 | 
			
		||||
 | 
			
		||||
func (this *NodeMonitorTask) loop() error {
 | 
			
		||||
	// 检查上次运行时间,防止重复运行
 | 
			
		||||
	settingKey := "node_monitor"
 | 
			
		||||
	settingKey := models.SettingCodeNodeMonitor
 | 
			
		||||
	timestamp := time.Now().Unix()
 | 
			
		||||
	c, err := models.SharedSysSettingDAO.CompareInt64Setting(settingKey, timestamp-int64(this.intervalSeconds))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user