本文整理汇总了Golang中github.com/elastic/libbeat/logp.LogInit函数的典型用法代码示例。如果您正苦于以下问题:Golang LogInit函数的具体用法?Golang LogInit怎么用?Golang LogInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogInit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: configureLogp
// Initializes logp if the verbose flag was set.
func configureLogp() {
oneTimeLogpInit.Do(func() {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"eventlog"})
logp.Info("DEBUG enabled for eventlog.")
} else {
logp.LogInit(logp.LOG_WARNING, "", false, true, []string{})
}
})
}
开发者ID:andrewkroh,项目名称:winlogbeat,代码行数:11,代码来源:eventlog_integration_test.go
示例2: TestMySQLParser_simpleUpdateResponse
func TestMySQLParser_simpleUpdateResponse(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"mysqldetailed"})
}
data := []byte("300000010001000100000028526f7773206d6174636865643a203120204368616e6765643a203120205761726e696e67733a2030")
message, err := hex.DecodeString(string(data))
if err != nil {
t.Errorf("Failed to decode hex string")
}
stream := &MysqlStream{data: message, message: new(MysqlMessage)}
ok, complete := mysqlMessageParser(stream)
if !ok {
t.Errorf("Parsing returned error")
}
if !complete {
t.Errorf("Expecting a complete message")
}
if stream.message.IsRequest {
t.Errorf("Failed to parse MySQL Query response")
}
if !stream.message.IsOK || stream.message.IsError {
t.Errorf("Failed to true, true, parse MySQL Query response")
}
if stream.message.AffectedRows != 1 {
t.Errorf("Failed to get the number of affected rows")
}
if stream.message.Size != 52 {
t.Errorf("Wrong message size %d", stream.message.Size)
}
}
开发者ID:venkateshdaram434,项目名称:packetbeat,代码行数:35,代码来源:mysql_test.go
示例3: TestHttpParser_censorPasswordPOST
func TestHttpParser_censorPasswordPOST(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"http", "httpdetailed"})
}
http := httpModForTests()
http.HideKeywords = []string{"password"}
http.parserConfig.SendHeaders = true
http.parserConfig.SendAllHeaders = true
data1 :=
"POST /users/login HTTP/1.1\r\n" +
"HOST: www.example.com\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Content-Length: 28\r\n" +
"\r\n" +
"username=ME&password=secret\r\n"
tp := newTestParser(http, data1)
msg, ok, complete := tp.parse()
assert.True(t, ok)
assert.True(t, complete)
rawMsg := tp.stream.data[tp.stream.message.start:tp.stream.message.end]
path, params, err := http.extractParameters(msg, rawMsg)
assert.Nil(t, err)
assert.Equal(t, "/users/login", path)
assert.False(t, strings.Contains(params, "secret"))
}
开发者ID:bqk-,项目名称:packetbeat,代码行数:30,代码来源:http_test.go
示例4: TestOneHost500Resp
func TestOneHost500Resp(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"elasticsearch"})
}
index := fmt.Sprintf("packetbeat-unittest-%d", os.Getpid())
body := map[string]interface{}{
"user": "test",
"post_date": "2009-11-15T14:12:12",
"message": "trying out",
}
server := ElasticsearchMock(http.StatusInternalServerError, []byte("Something wrong happened"))
client := NewClient(server.URL, "", nil, nil, "", "")
err := client.Connect(1 * time.Second)
if err != nil {
t.Fatalf("Failed to connect: %v", err)
}
params := map[string]string{
"refresh": "true",
}
_, _, err = client.Index(index, "test", "1", params, body)
if err == nil {
t.Errorf("Index() should return error.")
}
if !strings.Contains(err.Error(), "500 Internal Server Error") {
t.Errorf("Should return <500 Internal Server Error> instead of %v", err)
}
}
开发者ID:hmalphettes,项目名称:dockerbeat,代码行数:34,代码来源:api_mock_test.go
示例5: Test_Rotator_By_Bytes
func Test_Rotator_By_Bytes(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"rotator"})
}
dir, err := ioutil.TempDir("", "test_rotator_")
if err != nil {
t.Errorf("Error: %s", err.Error())
return
}
logp.Debug("rotator", "Direcotry: %s", dir)
rotator := FileRotator{
Path: dir,
Name: "packetbeat",
RotateEveryBytes: 100,
KeepFiles: 7,
}
for i := 0; i < 300; i++ {
rotator.WriteLine([]byte("01234567890"))
}
}
开发者ID:avldya,项目名称:packetbeat,代码行数:25,代码来源:file_test.go
示例6: TestThrift_Parse_OneWayCallWithFin
func TestThrift_Parse_OneWayCallWithFin(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"thrift", "thriftdetailed"})
}
var thrift Thrift
thrift.Init(true, nil)
thrift.TransportType = ThriftTFramed
thrift.PublishQueue = make(chan *ThriftTransaction, 10)
tcptuple := testTcpTuple()
req := createTestPacket(t, "0000001080010001000000037a69700000000000")
var private thriftPrivateData
thrift.Parse(req, tcptuple, 0, private)
thrift.ReceivedFin(tcptuple, 0, private)
trans := expectThriftTransaction(t, thrift)
if trans.Request.Method != "zip" ||
trans.Request.Params != "()" ||
trans.Reply != nil || trans.ResponseTime != 0 {
t.Error("Bad result:", trans)
}
}
开发者ID:avldya,项目名称:packetbeat,代码行数:28,代码来源:thrift_test.go
示例7: TestThrift_Parse_RequestReplyMismatch
func TestThrift_Parse_RequestReplyMismatch(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"thrift", "thriftdetailed"})
}
var thrift Thrift
thrift.Init(true, nil)
thrift.TransportType = ThriftTFramed
thrift.PublishQueue = make(chan *ThriftTransaction, 10)
tcptuple := testTcpTuple()
reqzip := createTestPacket(t, "0000001080010001000000037a69700000000000")
repladd := createTestPacket(t, "000000178001000200000003616464000000000800000000000200")
var private thriftPrivateData
thrift.Parse(reqzip, tcptuple, 0, private)
thrift.Parse(repladd, tcptuple, 1, private)
// Nothing should be received at this point
select {
case trans := <-thrift.PublishQueue:
t.Error("Bad result:", trans)
default:
// ok
}
}
开发者ID:avldya,项目名称:packetbeat,代码行数:28,代码来源:thrift_test.go
示例8: TestThrift_ParseSimpleTFramedSplitInterleaved
func TestThrift_ParseSimpleTFramedSplitInterleaved(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"thrift", "thriftdetailed"})
}
var thrift Thrift
thrift.Init(true, nil)
thrift.TransportType = ThriftTFramed
thrift.PublishQueue = make(chan *ThriftTransaction, 10)
tcptuple := testTcpTuple()
req_half1 := createTestPacket(t, "0000001e8001000100")
repl_half1 := createTestPacket(t, "000000178001000200000003")
req_half2 := createTestPacket(t, "000003616464000000000800010000000108"+
"00020000000100")
repl_half2 := createTestPacket(t, "616464000000000800000000000200")
var private thriftPrivateData
private = thrift.Parse(req_half1, tcptuple, 0, private).(thriftPrivateData)
private = thrift.Parse(req_half2, tcptuple, 0, private).(thriftPrivateData)
private = thrift.Parse(repl_half1, tcptuple, 1, private).(thriftPrivateData)
thrift.Parse(repl_half2, tcptuple, 1, private)
trans := expectThriftTransaction(t, thrift)
if trans.Request.Method != "add" ||
trans.Request.Params != "(1: 1, 2: 1)" ||
trans.Reply.ReturnValue != "2" {
t.Error("Bad result:", trans)
}
}
开发者ID:avldya,项目名称:packetbeat,代码行数:34,代码来源:thrift_test.go
示例9: TestThrift_ParseSimpleTBinary
func TestThrift_ParseSimpleTBinary(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"thrift", "thriftdetailed"})
}
var thrift Thrift
thrift.Init(true, nil)
thrift.PublishQueue = make(chan *ThriftTransaction, 10)
tcptuple := testTcpTuple()
req := createTestPacket(t, "800100010000000470696e670000000000")
repl := createTestPacket(t, "800100020000000470696e670000000000")
var private thriftPrivateData
thrift.Parse(req, tcptuple, 0, private)
thrift.Parse(repl, tcptuple, 1, private)
trans := expectThriftTransaction(t, thrift)
if trans.Request.Method != "ping" ||
trans.Request.Params != "()" ||
trans.Reply.ReturnValue != "" ||
trans.Request.FrameSize == 0 ||
trans.Reply.FrameSize == 0 {
t.Error("Bad result:", trans)
}
}
开发者ID:avldya,项目名称:packetbeat,代码行数:29,代码来源:thrift_test.go
示例10: TestDeadTimeout
func TestDeadTimeout(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"elasticsearch"})
}
var pool ConnectionPool
urls := []string{"localhost:9200", "localhost:9201"}
err := pool.SetConnections(urls, "test", "secret")
if err != nil {
t.Errorf("Fail to set the connections: %s", err)
}
pool.SetDeadTimeout(10)
conn := pool.GetConnection()
if conn.URL != "localhost:9200" {
t.Errorf("Wrong connection returned: %s", conn.URL)
}
pool.MarkDead(conn)
time.Sleep(10 * time.Second)
conn = pool.GetConnection()
if conn.URL != "localhost:9201" {
t.Errorf("Wrong connection returned: %s", conn.URL)
}
conn = pool.GetConnection()
if conn.URL != "localhost:9200" {
t.Errorf("Wrong connection returned: %s", conn.URL)
}
}
开发者ID:postfix,项目名称:filebeat,代码行数:34,代码来源:connection_pool_test.go
示例11: TestThrift_ParseObfuscateStrings
func TestThrift_ParseObfuscateStrings(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"thrift", "thriftdetailed"})
}
var thrift Thrift
thrift.Init(true, nil)
thrift.TransportType = ThriftTFramed
thrift.ObfuscateStrings = true
thrift.PublishQueue = make(chan *ThriftTransaction, 10)
tcptuple := testTcpTuple()
req := createTestPacket(t, "00000024800100010000000b6563686f5f737472696e670000"+
"00000b00010000000568656c6c6f00")
repl := createTestPacket(t, "00000024800100020000000b6563686f5f737472696e67000"+
"000000b00000000000568656c6c6f00")
var private thriftPrivateData
thrift.Parse(req, tcptuple, 0, private)
thrift.Parse(repl, tcptuple, 1, private)
trans := expectThriftTransaction(t, thrift)
if trans.Request.Method != "echo_string" ||
trans.Request.Params != `(1: "*")` ||
trans.Reply.ReturnValue != `"*"` {
t.Error("Bad result:", trans)
}
}
开发者ID:avldya,项目名称:packetbeat,代码行数:32,代码来源:thrift_test.go
示例12: TestThrift_Parse_Exception
func TestThrift_Parse_Exception(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"thrift", "thriftdetailed"})
}
var thrift Thrift
thrift.Init(true, nil)
thrift.PublishQueue = make(chan *ThriftTransaction, 10)
tcptuple := testTcpTuple()
req := createTestPacket(t, "800100010000000963616c63756c6174650000000008000"+
"1000000010c00020800010000000108000200000000080003000000040000")
repl := createTestPacket(t, "800100020000000963616c63756c617465000000000c00"+
"01080001000000040b00020000001243616e6e6f742064697669646520627920300000")
var private thriftPrivateData
thrift.Parse(req, tcptuple, 0, private)
thrift.Parse(repl, tcptuple, 1, private)
trans := expectThriftTransaction(t, thrift)
if trans.Request.Method != "calculate" ||
trans.Request.Params != "(1: 1, 2: (1: 1, 2: 0, 3: 4))" ||
trans.Reply.Exceptions != `(1: (1: 4, 2: "Cannot divide by 0"))` ||
!trans.Reply.HasException {
t.Error("Bad result:", trans)
}
}
开发者ID:avldya,项目名称:packetbeat,代码行数:31,代码来源:thrift_test.go
示例13: TestPgsqlParser_incomplete_response
// Test parsing an incomplete pgsql response
func TestPgsqlParser_incomplete_response(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"pgsql", "pgsqldetailed"})
}
pgsql := PgsqlModForTests()
data := []byte(
"54000000420003610000004009000100000413ffffffffffff0000620000004009000200000413ffffffffffff0000630000004009000300000413ffffffffffff0000" +
"440000001b0003000000036d6561000000036d6562000000036d6563" +
"440000001e0003000000046d656131000000046d656231000000046d656331" +
"440000001e0003000000046d")
message, err := hex.DecodeString(string(data))
if err != nil {
t.Error("Failed to decode hex string")
}
stream := &PgsqlStream{data: message, message: new(PgsqlMessage)}
ok, complete := pgsql.pgsqlMessageParser(stream)
if !ok {
t.Error("Parsing returned error")
}
if complete {
t.Error("Expecting an incomplete message")
}
}
开发者ID:navenel,项目名称:packetbeat,代码行数:30,代码来源:pgsql_test.go
示例14: TestOneHost503Resp
func TestOneHost503Resp(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"elasticsearch"})
}
index := fmt.Sprintf("packetbeat-unittest-%d", os.Getpid())
body := map[string]interface{}{
"user": "test",
"post_date": "2009-11-15T14:12:12",
"message": "trying out",
}
server := ElasticsearchMock(503, []byte("Something wrong happened"))
es := NewElasticsearch([]string{server.URL}, nil, "", "")
params := map[string]string{
"refresh": "true",
}
_, err := es.Index(index, "test", "1", params, body)
if err == nil {
t.Errorf("Index() should return error.")
}
if !strings.Contains(err.Error(), "retries. Errors") {
t.Errorf("Should return <Request fails after 3 retries. Errors: > instead of %v", err)
}
}
开发者ID:navenel,项目名称:packetbeat,代码行数:29,代码来源:api_mock_test.go
示例15: BenchmarkIcmpProcessICMPv4
func BenchmarkIcmpProcessICMPv4(b *testing.B) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"icmp", "icmpdetailed"})
}
results := publisher.ChanClient{make(chan common.MapStr, 10)}
icmp, err := NewIcmp(true, results)
if err != nil {
b.Error("Failed to create ICMP processor")
return
}
icmpRequestData := createICMPv4Layer(b, "08"+"00"+"0000"+"ffff"+"0001")
packetRequestData := new(protos.Packet)
icmpResponseData := createICMPv4Layer(b, "00"+"00"+"0000"+"ffff"+"0001")
packetResponseData := new(protos.Packet)
b.ResetTimer()
for n := 0; n < b.N; n++ {
icmp.ProcessICMPv4(icmpRequestData, packetRequestData)
icmp.ProcessICMPv4(icmpResponseData, packetResponseData)
client := icmp.results.(publisher.ChanClient)
<-client.Channel
}
}
开发者ID:bqk-,项目名称:packetbeat,代码行数:28,代码来源:icmp_test.go
示例16: TestMultipleFailingHosts
func TestMultipleFailingHosts(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"elasticsearch"})
}
index := fmt.Sprintf("packetbeat-unittest-%d", os.Getpid())
body := map[string]interface{}{
"user": "test",
"post_date": "2009-11-15T14:12:12",
"message": "trying out",
}
server1 := ElasticsearchMock(503, []byte("Something went wrong"))
server2 := ElasticsearchMock(500, []byte("Something went wrong"))
logp.Debug("elasticsearch", "%s, %s", server1.URL, server2.URL)
es := NewElasticsearch([]string{server1.URL, server2.URL}, nil, "", "")
params := map[string]string{
"refresh": "true",
}
_, err := es.Index(index, "test", "1", params, body)
if err == nil {
t.Errorf("Index() should return error.")
}
if !strings.Contains(err.Error(), "500 Internal Server Error") {
t.Errorf("Should return <500 Internal Server Error> instead of %v", err)
}
}
开发者ID:navenel,项目名称:packetbeat,代码行数:31,代码来源:api_mock_test.go
示例17: TestOneHostSuccessResp
func TestOneHostSuccessResp(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"elasticsearch"})
}
index := fmt.Sprintf("packetbeat-unittest-%d", os.Getpid())
body := map[string]interface{}{
"user": "test",
"post_date": "2009-11-15T14:12:12",
"message": "trying out",
}
expectedResp, _ := json.Marshal(QueryResult{Ok: true, Index: index, Type: "test", ID: "1", Version: 1, Created: true})
server := ElasticsearchMock(200, expectedResp)
es := NewElasticsearch([]string{server.URL}, nil, "", "")
params := map[string]string{
"refresh": "true",
}
resp, err := es.Index(index, "test", "1", params, body)
if err != nil {
t.Errorf("Index() returns error: %s", err)
}
if !resp.Created {
t.Errorf("Index() fails: %s", resp)
}
}
开发者ID:navenel,项目名称:packetbeat,代码行数:29,代码来源:api_mock_test.go
示例18: TestDeadTimeout
func TestDeadTimeout(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"elasticsearch"})
}
var pool ConnectionPool
urls := []string{"localhost:9200", "localhost:9201"}
err := pool.SetConnections(urls, "test", "secret")
if err != nil {
t.Errorf("Fail to set the connections: %s", err)
}
// Set dead timeout to zero so that dead connections are immediately
// returned to the pool.
pool.SetDeadTimeout(0)
conn := pool.GetConnection()
assertExpectedConnectionURL(t, conn.URL, urls[0])
pool.MarkDead(conn)
time.Sleep(10 * time.Millisecond)
assertExpectedConnectionURL(t, pool.GetConnection().URL, urls[1])
assertExpectedConnectionURL(t, pool.GetConnection().URL, urls[0])
}
开发者ID:rayyang2000,项目名称:topbeat,代码行数:25,代码来源:connection_pool_test.go
示例19: TestHttpParser_301_response
func TestHttpParser_301_response(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"http"})
}
data := "HTTP/1.1 301 Moved Permanently\r\n" +
"Date: Sun, 29 Sep 2013 16:53:59 GMT\r\n" +
"Server: Apache\r\n" +
"Location: http://www.hotnews.ro/\r\n" +
"Vary: Accept-Encoding\r\n" +
"Content-Length: 290\r\n" +
"Connection: close\r\n" +
"Content-Type: text/html; charset=iso-8859-1\r\n" +
"\r\n" +
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n" +
"<html><head>\r\n" +
"<title>301 Moved Permanently</title>\r\n" +
"</head><body>\r\n" +
"<h1>Moved Permanently</h1>\r\n" +
"<p>The document has moved <a href=\"http://www.hotnews.ro/\">here</a>.</p>\r\n" +
"<hr>\r\n" +
"<address>Apache Server at hotnews.ro Port 80</address>\r\n" +
"</body></html>"
msg, ok, complete := testParse(nil, data)
assert.True(t, ok)
assert.True(t, complete)
assert.Equal(t, 290, msg.ContentLength)
}
开发者ID:bqk-,项目名称:packetbeat,代码行数:29,代码来源:http_test.go
示例20: TestThriftIdl_thriftReadFiles
func TestThriftIdl_thriftReadFiles(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"thrift", "thriftdetailed"})
}
idl := thriftIdlForTesting(t, `
/* simple test */
service Test {
i32 add(1:i32 num1, 2: i32 num2)
}
`)
methods_map := idl.MethodsByName
if len(methods_map) == 0 {
t.Error("Empty methods_map")
}
m, exists := methods_map["add"]
if !exists || m.Service == nil || m.Method == nil ||
m.Service.Name != "Test" || m.Method.Name != "add" {
t.Error("Bad data:", m)
}
if *m.Params[1] != "num1" || *m.Params[2] != "num2" {
t.Error("Bad params", m.Params)
}
if len(m.Exceptions) != 0 {
t.Error("Non empty exceptions", m.Exceptions)
}
}
开发者ID:avldya,项目名称:packetbeat,代码行数:30,代码来源:thrift_idl_test.go
注:本文中的github.com/elastic/libbeat/logp.LogInit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论