當前位置: 首頁>>代碼示例>>Golang>>正文


Golang jklog.L函數代碼示例

本文整理匯總了Golang中jk/jklog.L函數的典型用法代碼示例。如果您正苦於以下問題:Golang L函數的具體用法?Golang L怎麽用?Golang L使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了L函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
	flag.Parse()
	if len(*filename) == 0 {
		jklog.L().Errorln("I must know what file to do with ...")
		return
	}

	if *revert == false {
		todo := NewItoY("", "", "")
		err := todo.NewSaveWithDir(*filename, *saveposition)
		if err != nil && err != io.EOF {
			jklog.L().Errorln("err: ", err)
			return
		}
	} else {

		todo := NewItoY("", "", "")
		err := todo.NewSaveWithDirRevert(*filename, *saveposition)
		if err != nil && err != io.EOF {
			jklog.L().Errorln("error : ", err)
			return
		}

	}

	jklog.L().Infoln("Do it success ...")
	return
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:28,代碼來源:itoy.go

示例2: DoCommand

func (debug *JKDeviceDebug) DoCommand(cmd, args string) string {
	err := debug.sendCommandOut(cmd, args)
	if err != nil {
		return ""
	}

	// wait the result of the data.
	var resultData string
	//t := time.Now()
	for {
		//now := time.Now()
		//v := now - t
		//if v > 5 {
		//	break
		//}
		recvData := make([]byte, 1024)
		n, err := debug.conn.Read(recvData)
		if io.EOF == err {
			break
		}
		if err != nil {
			jklog.L().Errorln("read error : ", err)
			break
		}
		// resultData = make([]byte, n)
		// resultData = append(resultData, recvData[0:n])
		if n > 0 {
			resultData += string(recvData[0:n])
		}
		jklog.L().Infof("recv data [%s], len [%d]\n", recvData, n)
		break
	}
	return string(resultData)
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:34,代碼來源:jknetwork.go

示例3: JKSendUDPCommand

func (cm *JKConnectManager) JKSendUDPCommand(addr string, data string) error {
	if len(addr) <= 0 {
		addr = cm.FromAddr
	}
	ln, err := net.ResolveUDPAddr("udp", addr+":"+strconv.Itoa(JK_LISTEN_PORT))
	if err != nil {
		jklog.L().Errorln("resolve udp fail of addr ", addr, " error :", err)
		return err
	}

	cn, err := net.DialUDP("udp", nil, ln)
	if err != nil {
		jklog.L().Errorln("Dial udp fail of addr ", addr, " error : ", err)
		return err
	}
	defer cn.Close()
	n, err := cn.Write([]byte(data))
	if err != nil {
		jklog.L().Errorln("write to addr ", addr, " fail ", err)
		return err
	}
	jklog.L().Debugln("send out to ", addr, " data of len ", n)
	jklog.L().Debugln("send out data are : ", data)
	return nil
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:25,代碼來源:jkconnectmanager.go

示例4: JKSaveFileData

func JKSaveFileData(id, filename, data string) bool {
	filepath := "./" + JK_SERVER_FILE_POSITION + "/" + id + "/" + filename
	prefix := os.Getenv("HOME")
	if len(prefix) > 0 {
		filepath = prefix + "/" + JK_SERVER_FILE_POSITION + "/" + id + "/" + filename
	}
	indx := strings.LastIndex(filepath, "/")
	if indx > 0 {
		dirs := filepath[0:indx]
		err := os.MkdirAll(dirs, os.ModePerm)
		if err != nil {
			jklog.L().Errorln("create dir failed: ", err)
			return false
		}
	}

	f, err := os.OpenFile(filepath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
	if err != nil {
		f, err = os.Create(filepath)
		if err != nil {
			jklog.L().Errorf("Open %s failed %v\n", filepath, err)
			return false
		}
	}

	defer f.Close()

	_, err = f.WriteString(data)
	if err != nil {
		jklog.L().Errorln("Write data failed: ", err)
		return false
	}
	return true
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:34,代碼來源:jkcommon.go

示例5: JKParseDocStart

// Parse start here, give one file or dir
// It will check all file if give dir
// @docsname: create what dir to save docs
func JKParseDocStart(filename string, docsname string) {
	jklog.L().SetLevel(jklog.LEVEL_MUCH)
	jklog.L().Infoln("parse doc start ", filename)

	p := &JKParseDoc{}

	// create docsname if it is not exists.
	err := os.Mkdir(docsname, os.ModeDir)
	if err != nil {
		// docs not exists.
		os.Create(docsname)
	}

	p.prefix = docsname

	dir, err := os.Stat(filename)
	if err != nil {
		return
	}
	if dir.IsDir() {
		err = p.parse_dir_files(filename)
		if err != nil {
			jklog.L().Errorln("pasre dir : ", err)
		}
		// Only dir need generate index file
		p.generateIndexFile()
	} else {
		p.files = append(p.files, filename)
	}
	// p.Output()
	p.parse_files()

	jklog.L().Infoln("All done, exist...")
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:37,代碼來源:jkparsedoc.go

示例6: receiverAndOutResponse

func receiverAndOutResponse(listen, cmd string) {
	jklog.L().Infoln("Receiver data from [", listen, "] of file ", cmd)

	lListen, err := net.Listen("tcp", listen)
	if err != nil {
		return
	}
	defer lListen.Close()

	c, err := lListen.Accept()
	if err != nil {
		jklog.L().Errorln("Accept error : ", err)
		return
	}

	for {
		recvdata := make([]byte, 1024)

		// go func() {
		n, err := c.Read(recvdata)
		if io.EOF == err {
			time.Sleep(10 * time.Microsecond)
			break
		}
		if err != nil {
			jklog.L().Errorln("read error : ", err)
			break
		}
		jklog.L().Infof("recv data [%s], len [%d]\n", recvdata, n)
	}
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:31,代碼來源:bvpudebug.go

示例7: jk_send_query

func jk_send_query(addr string) {
	jklog.L().Infoln("Start to connect to ", addr)
	_, err := net.Dial("tcp", addr+":"+strconv.Itoa(JK_CONNECT_TO_PORT))
	if err != nil {
		jklog.L().Errorln("Dial fail of ", addr+":"+strconv.Itoa(JK_CONNECT_TO_PORT), " ", err)
		return
	}
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:8,代碼來源:jkconnectmanager.go

示例8: main

func main() {
	v := 231
	buf := BytesToInt(int64(v), 4)
	jklog.L().Infoln("buf: ", buf)

	v1 := IntToBytes(buf)
	jklog.L().Infoln("int: ", int(v1))
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:8,代碼來源:bytes_int.go

示例9: jk_dial_udp_ext_data

func jk_dial_udp_ext_data(mac, ip string, port int, cmdType int, dlen int, dstring string) error {
	// start to send command to everywhere through udp
	ser, err := net.ResolveUDPAddr("udp", ip+":"+strconv.Itoa(port))
	if err != nil {
		return err
	}
	// jklog.L().Infoln("dial udp ", ser.IP, ser.Port, ser.Zone, ser.Network(), ser.String())
	dialout, err := net.DialUDP("udp", nil, ser)
	if err != nil {
		return err
	}

	// version dstmac srcmac sessionid dataid cmdtype datalen data

	// inmac := []byte(mac)
	lm := jk_get_mac_addr()

	jklog.L().Infoln("The mac addr ", lm)

	b_buf := bytes.NewBuffer([]byte{})
	binary.Write(b_buf, binary.LittleEndian, int32(cmdType))
	cmdbuf := b_buf.Bytes()
	// jklog.L().Infoln("cmd type ", cmdType, ", b_buf ", cmdbuf)

	dlenbuf := []byte{0, 0, 0, 0}
	if dlen > 0 {
		binary.Write(b_buf, binary.LittleEndian, int32(dlen))
		dlenbuf = b_buf.Bytes()
	}

	// 00 00 00 00 ff ff ff ff ff ff 00 0d 60 dc c3 d3 74 65 6d 70 00 00 00 80 01 00 00 00 00 00 00 00
	sendstr := []byte{
		0, 0, 0, 0,
		0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
		lm[0], lm[1], lm[2], lm[3], lm[4], lm[5],
		0x4, 0x1, 0x2, 0x3,
		0x0, 0x0, 0x0, 0x80,
		cmdbuf[0], cmdbuf[1], cmdbuf[2], cmdbuf[3],
		dlenbuf[0], dlenbuf[1], dlenbuf[2], dlenbuf[3],
	}

	if dlen > 0 {
		dialout.Write(sendstr)
	} else {
		v := []byte(dstring)
		for _, t := range v {
			sendstr = append(sendstr, t)
		}
		dialout.Write(sendstr)
	}

	jklog.L().Debugln("send string to udp ", port, " down!")

	dialout.Close()
	return nil
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:56,代碼來源:bvconn.go

示例10: sendCommandOut

func (debug *JKDeviceDebug) sendCommandOut(cmd, args string) error {
	sendData := cmd + "[" + args + "]"
	n, err := debug.conn.Write([]byte(sendData))
	if err != nil {
		jklog.L().Errorln("write command failed ", sendData, " with error ", err)
		return err
	} else {
		jklog.L().Infoln("write done data ", sendData, " with len ", n)
	}
	return nil
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:11,代碼來源:jknetwork.go

示例11: WriteRequest

/** return len of write */
func (s *SmartEye) WriteRequest(value string) int {
	if s.conn == nil {
		jklog.L().Errorln("no connect")
		return 0
	}
	w, err := s.conn.Write([]byte(value + "\r\n"))
	if err == nil {
		return w
	}
	jklog.L().Errorln("write error : ", err)
	return 0
}
開發者ID:jmdkina,項目名稱:jkgowindows,代碼行數:13,代碼來源:smarteye.go

示例12: startClient

func (c *KFClient) startClient(addr string, port int) bool {

	c.handle = cli.JKNewClientNew(addr, port)

reconn:
	ret := c.handle.CliConnect(0, true)
	if !ret {
		return false
	}

	// tmstr := fmt.Sprintf("%d", time.Now().Unix())
	p := NewJKProtocol()

	regstr := p.GenerateRegister(*id)

	n, err := c.handle.Write([]byte(regstr))
	if err != nil {
		jklog.L().Errorln("write failed: ", err)
		goto reconn
	}
	jklog.L().Debugln("write done of len: ", n)

	itemData := &cli.JKClientItem{}
	n, err = c.handle.Read(itemData)
	if err != nil {
		jklog.L().Errorln("read failed, ", err)

	} else {
		jklog.L().Infoln("read data: ", string(itemData.Data))
	}

	var startTime int64
	for {
		now := time.Now().Unix()

		if now-startTime < 300 {
			time.Sleep(time.Millisecond * 1000)
			continue
		}
		startTime = now

		wstr := p.GenerateControlSaveFile(*id+".log", "Hello, I'm online - "+time.Now().String())
		_, err = c.handle.Write([]byte(wstr))
		if err != nil {
			jklog.L().Errorln("write failed, ", err)
			goto reconn
		}
	}

	c.handle.Close()
	return true
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:52,代碼來源:jkclient.go

示例13: main

func main() {
	flag.Parse()

	http.Handle("/", http.FileServer(http.Dir(*dir)))
	inPort := *port
	if inPort[0] != ':' {
		inPort = ":" + inPort
	}
	jklog.L().Infof("Start server in %s with local %s\n", inPort, *dir)
	http.ListenAndServe(inPort, nil)

	jklog.L().Errorln("Failed listen in %s with local %s\n", inPort, *dir)
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:13,代碼來源:jkhttpserver.go

示例14: Read

/** read data, read 1024 every time
 *  return read len
 */
func (s *SmartEye) Read(buf []byte) int {
	if s.conn == nil {
		jklog.L().Errorln("no connect")
		return 0
	}
	buf = make([]byte, 1024)
	l, err := s.conn.Read(buf)
	if err == nil {
		return l
	}
	jklog.L().Errorln("read error : ", err)
	return 0
}
開發者ID:jmdkina,項目名稱:jkgowindows,代碼行數:16,代碼來源:smarteye.go

示例15: ExampleScrape

func ExampleScrape() {
	doc, err := goquery.NewDocument("http://www.rfcreader.com/#rfc3550")

	// doc, err := goquery.NewDocument("http://192.168.6.151")
	if err != nil {
		jklog.L().Errorln("error open the document:", err)
	}
	table := doc.Find("div")
	value := table.Text()
	jklog.L().Infoln("the table: ", value)
	// doc.Find("table").Each(func(i int, s *goquery.Selection) {
	// jklog.L().Infof("Review %d: %s \n", i, s.Text())
	// })
}
開發者ID:jmdkina,項目名稱:jkgo,代碼行數:14,代碼來源:parse-html.go


注:本文中的jk/jklog.L函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。