本文整理汇总了Golang中github.com/BestianRU/SABModules/SBMSystem.LogFile类的典型用法代码示例。如果您正苦于以下问题:Golang LogFile类的具体用法?Golang LogFile怎么用?Golang LogFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LogFile类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: InitS
func (_s *LDAP) InitS(rLog SBMSystem.LogFile, user, password, server string) int {
var err error
_s.CS = -1
rLog.LogDbg(2, "LDAP Init SRV ***** Trying connect to server ", server, " with login ", user)
_s.D, err = ldap.Dial("tcp", server)
if err != nil {
rLog.LogDbg(0, "LDAP::Dial() to server ", server, " error: ", err)
return -1
}
//L.Debug()
err = _s.D.Bind(user, password)
if err != nil {
rLog.LogDbg(1, "LDAP::Bind() to server ", server, " with login ", user, " error: ", err)
return -1
}
rLog.LogDbg(2, "LDAP Init SRV ***** Success! Connected to server ", server, " with login ", user)
_s.CS = 0
return 0
}
示例2: _getBaseDN
func (_s *LDAP) _getBaseDN(rLog SBMSystem.LogFile, search, basedn string) string {
var uattr = []string{"dn"}
lsearch := ldap.NewSearchRequest(basedn, 2, ldap.NeverDerefAliases, 0, 0, false, search, uattr, nil)
sr, err := _s.D.Search(lsearch)
if err != nil {
rLog.LogDbg(0, "LDAP::Search() ", basedn, " error: ", err)
}
if len(sr.Entries) > 0 {
for _, entry := range sr.Entries {
return entry.DN
}
}
return ""
}
示例3: _checkGroupMember
func (_s *LDAP) _checkGroupMember(rLog SBMSystem.LogFile, userDN, groupDN, baseDN string, recurse_count int) int {
var (
uattr = []string{"memberOf"}
result = int(-1)
)
if userDN == "" || groupDN == "" {
return -1
}
if recurse_count <= 0 {
return -1
}
lsearch := ldap.NewSearchRequest(userDN, 0, ldap.NeverDerefAliases, 0, 0, false, "(objectclass=*)", uattr, nil)
sr, err := _s.D.Search(lsearch)
if err != nil {
rLog.LogDbg(0, "LDAP::Search() ", userDN, " error: ", err)
}
if len(sr.Entries) > 0 {
for _, entry := range sr.Entries {
for _, attr := range entry.Attributes {
if attr.Name == "memberOf" {
for _, x := range attr.Values {
if groupDN == x {
return 0
} else {
if x != userDN {
result = _s._checkGroupMember(rLog, x, groupDN, baseDN, recurse_count-1)
if result == 0 {
return 0
}
}
}
}
}
}
}
}
return -1
}
示例4: CheckGroupMember
func (_s *LDAP) CheckGroupMember(rLog SBMSystem.LogFile, user, group, baseDN string) int {
const (
recurs_count = 10
)
rLog.LogDbg(2, "LDAP CheckGroupMember...")
userDN := _s._getBaseDN(rLog, user, baseDN)
groupDN := _s._getBaseDN(rLog, group, baseDN)
if userDN == "" || groupDN == "" {
return -1
}
if _s._checkGroupMember(rLog, userDN, groupDN, baseDN, 1) == 0 {
return 0
} else {
return _s._checkGroupMember(rLog, userDN, groupDN, baseDN, recurs_count)
}
return -1
}
示例5: Init
func (_s *LDAP) Init(conf SBMSystem.ReadJSONConfig, rLog SBMSystem.LogFile) int {
var (
attemptCounter = int(0)
err error
)
_s.CS = -1
for {
if attemptCounter > len(conf.Conf.LDAP_URL)*2 {
rLog.LogDbg(0, "LDAP Init SRV ***** Error connect to all LDAP servers !!!")
return -1
}
if LDAPCounter > len(conf.Conf.LDAP_URL)-1 {
LDAPCounter = 0
}
rLog.LogDbg(2, "LDAP Init SRV ***** Trying connect to server ", LDAPCounter+1, " of ", len(conf.Conf.LDAP_URL), ": ", conf.Conf.LDAP_URL[LDAPCounter][0])
_s.D, err = ldap.Dial("tcp", conf.Conf.LDAP_URL[LDAPCounter][0])
if err != nil {
LDAPCounter++
attemptCounter++
continue
}
rLog.LogDbg(2, "LDAP Init SRV ***** Success! Connected to server ", LDAPCounter+1, " of ", len(conf.Conf.LDAP_URL), ": ", conf.Conf.LDAP_URL[LDAPCounter][0])
LDAPCounter++
break
}
//_s.D.Debug()
err = _s.D.Bind(conf.Conf.LDAP_URL[0][1], conf.Conf.LDAP_URL[0][2])
if err != nil {
rLog.LogDbg(0, "LDAP::Bind() to server ", conf.Conf.LDAP_URL[LDAPCounter][0], " with login ", conf.Conf.LDAP_URL[0][1], " error: ", err)
return -1
}
_s.CS = 0
return 0
}
示例6: main
func main() {
var (
jsonConfig SBMSystem.ReadJSONConfig
rLog SBMSystem.LogFile
pg SBMConnect.PgSQL
)
const (
pName = string("SABook CardDAVMaker Poller")
pVer = string("5 2015.11.25.21.00")
)
jsonConfig.Init("./CardDAVMaker.log", "./CardDAVMaker.json")
rLog.ON(jsonConfig)
if pg.Init(jsonConfig, "insert into aaa_dav_ntu values (0,123);") != 0 {
rLog.Log("POLLER: Poll insert error!")
}
defer pg.Close()
rLog.OFF()
}
示例7: goNTUWork
func goNTUWork(conf SBMSystem.ReadJSONConfig, rLog SBMSystem.LogFile) {
type usIDPartList struct {
id int
name string
}
var (
ldap_Attr []string
ldap_VCard []string
queryx string
multiInsert = int(64)
//idxUsers = int(1)
idxCards = int(1)
workMode = string("FULL")
i int
pg SBMConnect.PgSQL
my SBMConnect.MySQL
ld SBMConnect.LDAP
err error
pgrows1 *sql.Rows
)
rLog.Log("--> WakeUP!")
for i = 0; i < len(conf.Conf.WLB_LDAP_ATTR); i++ {
ldap_Attr = append(ldap_Attr, conf.Conf.WLB_LDAP_ATTR[i][0])
ldap_VCard = append(ldap_VCard, conf.Conf.WLB_LDAP_ATTR[i][1])
}
if pg.Init(conf, "") < 0 {
log.Println("Init PgSQL Error!")
return
}
defer pg.Close()
if my.Init(conf, mySQL_InitDB) < 0 {
log.Println("Init MySQL Error!")
return
}
defer my.Close()
if ld.Init(conf) < 0 {
log.Println("Init LDAP Error!")
return
}
defer ld.Close()
time.Sleep(10 * time.Second)
x := make(map[string]string, len(ldap_Attr))
multiCount := 0
rLog.Log("\tCreate cacheDB from LDAP...")
time_now := time.Now().Unix()
time_get := pg.QSimple("select updtime from aaa_dav_ntu where userid=0;")
switch {
case time_get < 0:
log.Println("PgSQL: Error reading NTU table")
return
case time_get > 0:
pgrows1, err = pg.D.Query("select x.id, x.login, x.password, x.cdavprefix from aaa_logins as x where x.id in (select userid from aaa_dns where userid=x.id) order by login;")
if err != nil {
log.Printf("PG::Query() 02 error: %v\n", err)
return
}
workMode = "FULL"
case time_get == 0:
pgrows1, err = pg.D.Query("select x.id, x.login, x.password, x.cdavprefix from aaa_logins as x, aaa_dav_ntu as y where x.id=y.userid and x.id in (select userid from aaa_dns where userid=x.id) order by login;")
if err != nil {
log.Printf("PG::Query() 03 error: %v\n", err)
return
}
workMode = "PART"
}
usID := 0
usName := ""
usPass := ""
usCDavPrefix := 0
//userIDGet := 0
usIDArray := make([]usIDPartList, 0)
for pgrows1.Next() {
usCDavPrefix = 0
pgrows1.Scan(&usID, &usName, &usPass, &usCDavPrefix)
usIDArray = append(usIDArray, usIDPartList{id: usID, name: usName})
/*
userIDGet = my.QSimple("select id from users where username='", usName, "';")
switch {
case userIDGet < 0:
log.Println("Error get user ID")
return
case userIDGet > 0:
idxUsers = userIDGet
case userIDGet == 0:
userIDGet = my.QSimple("select id from users order by id desc limit 1;")
if userIDGet > 0 {
userIDGet++
//.........这里部分代码省略.........
示例8: main
func main() {
var (
jsonConfig SBMSystem.ReadJSONConfig
rLog SBMSystem.LogFile
pid SBMSystem.PidFile
sleepWatch = int(0)
)
const (
pName = string("SABook CardDAVMaker")
pVer = string("5 2015.11.25.21.00")
)
fmt.Printf("\n\t%s V%s\n\n", pName, pVer)
jsonConfig.Init("./CardDAVMaker.log", "./CardDAVMaker.json")
rLog.ON(jsonConfig)
pid.ON(jsonConfig)
pid.OFF(jsonConfig)
rLog.OFF()
SBMSystem.Fork(jsonConfig)
SBMSystem.Signal(jsonConfig, pid)
rLog.ON(jsonConfig)
pid.ON(jsonConfig)
defer pid.OFF(jsonConfig)
rLog.Hello(pName, pVer)
rLog.OFF()
for {
rLog.ON(jsonConfig)
jsonConfig.Update()
if checkNTUWishes(jsonConfig, rLog) > 0 {
rLog.Hello(pName, pVer)
goNTUWork(jsonConfig, rLog)
sleepWatch = 0
}
if sleepWatch > 3600 {
rLog.Log("<-- I'm alive ... :)")
sleepWatch = 0
}
rLog.OFF()
time.Sleep(time.Duration(jsonConfig.Conf.Sleep_Time) * time.Second)
sleepWatch += jsonConfig.Conf.Sleep_Time
}
}