本文整理汇总了Golang中github.com/toolkits/logger.Errorln函数的典型用法代码示例。如果您正苦于以下问题:Golang Errorln函数的具体用法?Golang Errorln怎么用?Golang Errorln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Errorln函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: InsureNewVersionFiles
func InsureNewVersionFiles(da *model.DesiredAgent) error {
if FilesReady(da) {
return nil
}
downloadTarballCmd := BuildCommand(da.RunUser, "wget", "-q", da.TarballUrl, "-O", path.Join(da.AgentVersionDir, da.TarballFilename))
downloadTarballCmd.Dir = file.SelfDir()
_, err := ExecuteCommandWithOutput(downloadTarballCmd)
if err != nil {
logger.Errorln("wget -q", da.TarballUrl, "-O", da.TarballFilename, "fail", err)
return err
}
downloadMd5Cmd := BuildCommand(da.RunUser, "wget", "-q", da.Md5Url, "-O", path.Join(da.AgentVersionDir, da.Md5Filename))
downloadMd5Cmd.Dir = file.SelfDir()
_, err = ExecuteCommandWithOutput(downloadMd5Cmd)
if err != nil {
log.Println("wget -q", da.Md5Url, "-O", da.Md5Filename, "fail", err)
return err
}
if "" != da.ConfigFileName && "" != da.ConfigRemoteUrl {
downloadConfigCmd := BuildCommand(da.RunUser, "wget", "-q", da.ConfigRemoteUrl, "-O", path.Join(da.AgentVersionDir, da.ConfigFileName))
downloadConfigCmd.Dir = file.SelfDir()
_, err := ExecuteCommandWithOutput(downloadConfigCmd)
if err != nil {
logger.Errorln("wget -q", da.ConfigRemoteUrl, "-O", da.ConfigFileName, "fail", err)
}
return err
}
return Md5sumCheck(da.RunUser, da.AgentVersionDir, da.TarballFilename, da.Md5Filename)
}
开发者ID:coraldane,项目名称:ops-updater,代码行数:33,代码来源:start.go
示例2: StartDesiredAgent
func StartDesiredAgent(da *model.DesiredAgent, last *model.DesiredAgent) error {
if err := InsureRunUserExists(da); nil != err {
return err
}
var lastRunUser, lastWorkDir string
if nil != last {
lastRunUser = last.RunUser
lastWorkDir = last.WorkDir
}
if err := StopAgentOf(da, lastRunUser, lastWorkDir); err != nil {
return err
}
if err := InsureNewVersion(da); nil != err {
return err
}
if err := ControlStartIn(da.RunUser, da.AgentVersionDir); err != nil {
logger.Errorln("ControlStartIn error", err)
return err
}
if err := WriteVersion(da); nil != err {
logger.Errorln("WriteVersion error", err)
return err
}
return nil
}
开发者ID:coraldane,项目名称:ops-updater,代码行数:30,代码来源:start.go
示例3: QueryRelEndpointGroupList
func QueryRelEndpointGroupList(queryDto QueryRelEndpointGroupDto, pageInfo *PageInfo) ([]RelEndpointGroup, *PageInfo) {
var rows []RelEndpointGroup
query := db.NewOrm().QueryTable(RelEndpointGroup{})
if 0 < queryDto.HostGroupId {
query = query.Filter("HostGroupId", queryDto.HostGroupId)
}
if "" != queryDto.RelType {
query = query.Filter("RelType", queryDto.RelType)
}
if "" != queryDto.PropName {
query = query.Filter("PropName", queryDto.PropName)
}
if "" != queryDto.PropValue {
query = query.Filter("PropValue", queryDto.PropValue)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("RelType").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows)
if nil != err {
logger.Errorln("QueryRelEndpointGroupList error", err)
}
return rows, pageInfo
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:30,代码来源:rel_endpoint_group.go
示例4: QueryUserList
func QueryUserList(queryDto QueryUserDto, pageInfo *PageInfo) ([]User, *PageInfo) {
var rows []User
query := db.NewOrm().QueryTable(User{})
if "" != queryDto.UserName {
query = query.Filter("user_name__contains", queryDto.UserName)
}
if "" != queryDto.RealName {
query = query.Filter("RealName", queryDto.RealName)
}
if "" != queryDto.RoleName {
query = query.Filter("RoleName", queryDto.RoleName)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("Id").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows,
"UserName", "RealName", "PhoneNo", "Email", "RoleName", "AccountStatus")
if nil != err {
logger.Errorln("QueryUserList error", err)
}
return rows, pageInfo
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:28,代码来源:user.go
示例5: ModifyRecord
func ModifyRecord(domainId int, recordId, subDomain, strIp string) bool {
data := url.Values{}
data.Add("login_email", g.Config().LoginEmail)
data.Add("login_password", g.Config().LoginPassword)
data.Add("format", "json")
data.Add("domain_id", strconv.Itoa(domainId))
data.Add("record_id", recordId)
data.Add("sub_domain", subDomain)
data.Add("record_type", "A")
data.Add("record_line", "默认")
data.Add("value", strIp)
strResponse, err := Post("https://dnsapi.cn/Record.Modify", data)
if nil != err {
logger.Errorln("RECORD_MODIFY ERROR", err)
} else {
logger.Infoln("RECORD_MODIFY_RESPONSE:", strResponse, err)
if "" != strResponse && strings.Contains(strResponse, `"code":"1"`) {
return true
} else {
logger.Infoln("domainId:%d,recordId:%s,sub_domain:%s\n", domainId, recordId, subDomain)
}
}
return false
}
开发者ID:coraldane,项目名称:dns-agent,代码行数:26,代码来源:start.go
示例6: Post
func (this *HeartbeatController) Post() {
jsonResult := make(map[string]interface{})
jsonResult["success"] = false
var req model.HeartbeatRequest
if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); nil != err {
logger.Errorln("parseForm error", err)
jsonResult["message"] = fmt.Sprintf("parseForm error: %v", err.Error())
} else if "" == req.Hostname {
jsonResult["message"] = "hostname is blank"
} else {
logger.Debugln("Heartbeat Request===>>>", req)
strIp := this.Ctx.Request.Header.Get("X-Forwarded-For")
if "" == strIp {
strIp = this.Ctx.Request.Header.Get("Proxy-Client-IP")
}
if "" == strIp {
strIp = this.Ctx.Request.Header.Get("WL-Proxy-Client-IP")
}
if "" == strIp {
ip, _, err := net.SplitHostPort(this.Ctx.Request.RemoteAddr)
if nil != err {
logger.Errorln("SplitHostPort error", this.Ctx.Request.RemoteAddr)
} else {
strIp = ip
}
}
go store.ParseHeartbeatRequest(&req, strIp)
resp := model.HeartbeatResponse{
ErrorMessage: "",
DesiredAgents: store.HostAgents.Status(req.Hostname),
}
logger.Debugln("Heartbeat Response<<<===", resp)
this.Data["json"] = &resp
jsonResult["success"] = true
}
if false == jsonResult["success"] {
this.Data["json"] = &jsonResult
}
this.ServeJSON()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:47,代码来源:heartbeat_controller.go
示例7: QueryEndpointAgentList
func QueryEndpointAgentList(hostname string) []EndpointAgent {
var rows []EndpointAgent
_, err := db.NewOrm().QueryTable(EndpointAgent{}).Filter("Hostname", hostname).All(&rows)
if nil != err {
logger.Errorln("QueryEndpointAgentList error", err)
}
return rows
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:8,代码来源:endpoint_agent.go
示例8: QueryRelAgentGroupList
func QueryRelAgentGroupList(agentId int64) ([]RelAgentGroupDto, error) {
var rows []RelAgentGroupDto
_, err := db.NewOrm().Raw("select t.id, t.gmt_create,t.gmt_modified, t.host_group_id, a.group_name from t_rel_agent_group t, t_host_group a where t.agent_id=? and t.host_group_id=a.id", agentId).QueryRows(&rows)
if nil != err {
logger.Errorln("QueryRelAgentGroupList error", err)
}
return rows, err
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:8,代码来源:rel_agent_group.go
示例9: GetUserById
func GetUserById(userId int64) *User {
var u User
strSql := `select id, user_name, real_name, phone_no, email, role_name, account_status from t_user where id=?`
err := db.NewOrm().Raw(strSql, userId).QueryRow(&u)
if nil != err {
logger.Errorln("query error", err)
}
return &u
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:9,代码来源:user.go
示例10: Update
func (this *User) Update() (int64, error) {
strSql := `update t_user set real_name=?, phone_no=?, email=?, role_name=? where id=?`
result, err := db.NewOrm().Raw(strSql, this.RealName, this.PhoneNo, this.Email, this.RoleName, this.Id).Exec()
if nil != err {
logger.Errorln("update error", err)
return 0, err
}
return result.RowsAffected()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:9,代码来源:user.go
示例11: ReadDesiredAgents
func ReadDesiredAgents() []*model.DesiredAgent {
var desiredAgents []*model.DesiredAgent
strJson, err := f.ToTrimString(path.Join(f.SelfDir(), "desired_agent.json"))
if nil != err {
logger.Errorln("read desired agent file error", err)
return desiredAgents
}
err = json.Unmarshal([]byte(strJson), &desiredAgents)
if nil != err {
logger.Errorln("unmarshal json error", strJson, err)
}
for _, da := range desiredAgents {
actualVersion := ReadVersion(da.RunUser, path.Join(da.WorkDir, da.Name))
if "" != actualVersion {
da.Version = actualVersion
}
}
return desiredAgents
}
开发者ID:coraldane,项目名称:ops-updater,代码行数:20,代码来源:request.go
示例12: QueryHostGroupList
func QueryHostGroupList(queryDto QueryHostGroupDto, pageInfo *PageInfo) ([]HostGroup, *PageInfo) {
var rows []HostGroup
query := db.NewOrm().QueryTable(HostGroup{})
if "" != queryDto.GroupName {
query = query.Filter("GroupName__contains", queryDto.GroupName)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("GroupName").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows)
if nil != err {
logger.Errorln("QueryHostGroupList error", err)
}
return rows, pageInfo
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:21,代码来源:host_group.go
示例13: SelectSessionBySig
func SelectSessionBySig(sig string) *Session {
if sig == "" {
return nil
}
obj := Session{Sig: sig}
err := orm.NewOrm().Read(&obj, "Sig")
if err != nil {
if err != orm.ErrNoRows {
logger.Errorln(err)
}
return nil
}
return &obj
}
开发者ID:hitripod,项目名称:fe,代码行数:15,代码来源:session.go
示例14: QueryEndpointList
func QueryEndpointList(queryDto QueryEndpointDto, pageInfo *PageInfo) ([]Endpoint, *PageInfo) {
var rows []Endpoint
query := db.NewOrm().QueryTable(Endpoint{})
if "" != queryDto.Hostname {
query = query.Filter("hostname__icontains", queryDto.Hostname)
}
if "" != queryDto.Ip {
query = query.Filter("ip__contains", queryDto.Ip)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("-GmtModified").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows)
if nil != err {
logger.Errorln("QueryEndpointList error", err)
}
return rows, pageInfo
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:24,代码来源:endpoint.go
示例15: SelectUserById
func SelectUserById(id int64) *User {
if id <= 0 {
return nil
}
obj := User{Id: id}
err := orm.NewOrm().Read(&obj, "Id")
if err != nil {
if err != orm.ErrNoRows {
logger.Errorln(err)
}
return nil
}
return &obj
}
开发者ID:LianjiaTech,项目名称:UIC,代码行数:15,代码来源:user.go
示例16: QueryAgentList
func QueryAgentList(queryDto QueryAgentDto, pageInfo *PageInfo) ([]Agent, *PageInfo) {
var rows []Agent
query := db.NewOrm().QueryTable(Agent{})
if "" != queryDto.AgentName {
query = query.Filter("Name", queryDto.AgentName)
}
if "" != queryDto.RunUser {
query = query.Filter("RunUser", queryDto.RunUser)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("Name").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows)
if nil != err {
logger.Errorln("QueryAgentList error", err)
}
return rows, pageInfo
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:24,代码来源:agent.go
示例17: heartbeat
func heartbeat() {
hostname, err := utils.Hostname(g.Config().Hostname)
if err != nil {
return
}
desiredAgents := ReadDesiredAgents()
heartbeatRequest := BuildHeartbeatRequest(hostname, desiredAgents)
logger.Debugln("===>>>", heartbeatRequest)
bs, err := json.Marshal(heartbeatRequest)
if err != nil {
logger.Errorln("encode heartbeat request fail", err)
return
}
url := fmt.Sprintf("http://%s/api/heartbeat", g.Config().Server)
httpRequest := httplib.Post(url).SetTimeout(time.Second*10, time.Minute)
httpRequest.Body(bs)
httpResponse, err := httpRequest.Bytes()
if err != nil {
log.Printf("curl %s fail %v", url, err)
return
}
var heartbeatResponse model.HeartbeatResponse
err = json.Unmarshal(httpResponse, &heartbeatResponse)
if err != nil {
logger.Errorln("decode heartbeat response fail", err)
return
}
logger.Debugln("<<<<====", heartbeatResponse)
HandleHeartbeatResponse(&heartbeatResponse, desiredAgents)
}
开发者ID:coraldane,项目名称:ops-updater,代码行数:36,代码来源:heartbeat.go
示例18: CheckFileOrDirExists
func CheckFileOrDirExists(username, fp, fileType string) bool {
if CurrentUser == username {
return file.IsExist(fp)
} else {
cmd := BuildCommand(username, "sh", "check_file.sh", fileType, fp)
cmd.Dir = file.SelfDir()
strOut, err := ExecuteCommandWithOutput(cmd)
if nil != err {
logger.Errorln("check dir exists", strOut, err)
return false
}
result, _ := strconv.ParseBool(strings.Replace(strOut, "\n", "", -1))
return result
}
return false
}
开发者ID:coraldane,项目名称:ops-updater,代码行数:16,代码来源:control.go
示例19: BuildHeartbeatRequest
func BuildHeartbeatRequest(hostname string, desiredAgents []*model.DesiredAgent) model.HeartbeatRequest {
req := model.HeartbeatRequest{Hostname: hostname}
req.Ip = utils.GetLocalIP()
req.UpdaterVersion = g.VERSION
req.RunUser = CurrentUser
realAgents := []*model.RealAgent{}
now := time.Now().Unix()
for _, da := range desiredAgents {
agentDir := path.Join(da.WorkDir, da.Name)
// 如果目录下没有.version,我们认为这根本不是一个agent
version := ReadVersion(da.RunUser, agentDir)
if "" == version {
logger.Error("read %s/.version fail\n", agentDir)
continue
}
controlFile := path.Join(agentDir, version, "control")
if !CheckFileExists(da.RunUser, controlFile) {
logger.Errorln(controlFile, "is nonexistent, user:", da.RunUser)
continue
}
cmd := BuildCommand(da.RunUser, path.Join(agentDir, version, "control"), "status")
cmd.Dir = f.SelfDir()
status, err := ExecuteCommandWithOutput(cmd)
if err != nil {
status = err.Error()
}
realAgent := &model.RealAgent{
Name: da.Name,
Version: version,
Status: status,
Timestamp: now,
}
realAgent.RunUser = da.RunUser
realAgent.WorkDir = da.WorkDir
realAgents = append(realAgents, realAgent)
}
req.RealAgents = realAgents
return req
}
开发者ID:coraldane,项目名称:ops-updater,代码行数:46,代码来源:request.go
示例20: Query
func (this *AgentController) Query() {
jsonResult := make(map[string]interface{})
pageInfo := models.NewPageInfo(this.Ctx.Request)
queryDto := models.QueryAgentDto{}
if err := this.ParseForm(&queryDto); nil != err {
logger.Errorln("parseForm error", err)
}
list, pageInfo := models.QueryAgentList(queryDto, pageInfo)
jsonResult["items"] = list
jsonResult["total"] = pageInfo.RowCount
this.Data["json"] = &jsonResult
this.ServeJSON()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:17,代码来源:agent_controller.go
注:本文中的github.com/toolkits/logger.Errorln函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论