本文整理汇总了Golang中github.com/elastic/beats/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", "eventlog_detail"})
logp.Info("DEBUG enabled for eventlog.")
} else {
logp.LogInit(logp.LOG_WARNING, "", false, true, []string{})
}
})
}
开发者ID:tsg,项目名称:beats,代码行数:11,代码来源:eventlog_integration_test.go
示例2: 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{})
}
// Clear the event log before starting.
log, _ := elog.Open(sourceName)
eventlogging.ClearEventLog(eventlogging.Handle(log.Handle), "")
log.Close()
})
}
开发者ID:urso,项目名称:beats,代码行数:16,代码来源:eventlogging_test.go
示例3: 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"))
client := NewClient(server.URL, "", nil, nil, "", "")
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(), "503 Service Unavailable") {
t.Errorf("Should return <503 Service Unavailable> instead of %v", err)
}
}
开发者ID:davidsoloman,项目名称:beats,代码行数:29,代码来源:api_mock_test.go
示例4: TestAmqp_RecoverMethod
func TestAmqp_RecoverMethod(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
amqp.sendRequest = true
data, err := hex.DecodeString("01000100000005003c006e01ce")
assert.Nil(t, err)
data2, err := hex.DecodeString("01000100000004003c006fce")
assert.Nil(t, err)
tcptuple := testTCPTuple()
req := protos.Packet{Payload: data}
private := protos.ProtocolData(new(amqpPrivateData))
private = amqp.Parse(&req, tcptuple, 0, private)
req = protos.Packet{Payload: data2}
amqp.Parse(&req, tcptuple, 1, private)
trans := expectTransaction(t, amqp)
assert.Equal(t, "basic.recover", trans["method"])
assert.Equal(t, "basic.recover", trans["request"])
assert.Equal(t, "amqp", trans["type"])
assert.Equal(t, common.OK_STATUS, trans["status"])
assert.Equal(t, common.MapStr{"requeue": true}, trans["amqp"])
}
开发者ID:ruflin,项目名称:beats,代码行数:28,代码来源:amqp_test.go
示例5: TestAmqp_GetEmptyMethod
func TestAmqp_GetEmptyMethod(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
amqp.sendRequest = true
data, err := hex.DecodeString("01000100000013003c004600000b526f626269" +
"654b65616e6501ce")
assert.Nil(t, err)
data2, err := hex.DecodeString("01000100000005003c004800ce")
assert.Nil(t, err)
tcptuple := testTCPTuple()
req := protos.Packet{Payload: data}
private := protos.ProtocolData(new(amqpPrivateData))
private = amqp.Parse(&req, tcptuple, 0, private)
req = protos.Packet{Payload: data2}
amqp.Parse(&req, tcptuple, 1, private)
trans := expectTransaction(t, amqp)
assert.Equal(t, "basic.get-empty", trans["method"])
assert.Equal(t, "basic.get RobbieKeane", trans["request"])
assert.Equal(t, "amqp", trans["type"])
assert.Equal(t, common.OK_STATUS, trans["status"])
}
开发者ID:ruflin,项目名称:beats,代码行数:28,代码来源:amqp_test.go
示例6: TestAmqp_NoWaitQueueDeleteMethod
func TestAmqp_NoWaitQueueDeleteMethod(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
amqp.sendRequest = true
data, err := hex.DecodeString("010001000000120032002800000a546573745468" +
"6f6d617304ce")
assert.Nil(t, err)
tcptuple := testTCPTuple()
req := protos.Packet{Payload: data}
private := protos.ProtocolData(new(amqpPrivateData))
amqp.Parse(&req, tcptuple, 0, private)
trans := expectTransaction(t, amqp)
assert.Equal(t, "queue.delete", trans["method"])
assert.Equal(t, "queue.delete TestThomas", trans["request"])
assert.Equal(t, "amqp", trans["type"])
fields, ok := trans["amqp"].(common.MapStr)
if !ok {
t.Errorf("Field should be present")
}
assert.Equal(t, true, fields["no-wait"])
assert.Equal(t, false, fields["if-empty"])
assert.Equal(t, false, fields["if-unused"])
assert.Equal(t, "TestThomas", fields["queue"])
}
开发者ID:ruflin,项目名称:beats,代码行数:33,代码来源:amqp_test.go
示例7: TestAmqp_ExchangeDeletion
func TestAmqp_ExchangeDeletion(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
data, err := hex.DecodeString("010001000000100028001400000844656c65746" +
"54d6501ce")
assert.Nil(t, err)
stream := &amqpStream{data: data, message: new(amqpMessage)}
m := stream.message
ok, complete := amqp.amqpMessageParser(stream)
if !ok {
t.Errorf("Parsing returned error")
}
if !complete {
t.Errorf("Message should be complete")
}
assert.Equal(t, "exchange.delete", m.method)
assert.Equal(t, "DeleteMe", m.fields["exchange"])
assert.Equal(t, "DeleteMe", m.request)
assert.Equal(t, true, m.fields["if-unused"])
assert.Equal(t, false, m.fields["no-wait"])
}
开发者ID:ruflin,项目名称:beats,代码行数:28,代码来源:amqp_test.go
示例8: TestAmqp_ExchangeDeclaration
func TestAmqp_ExchangeDeclaration(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
data, err := hex.DecodeString("0100010000001c0028000a00000a6c6f67735f746f7" +
"0696305746f7069630200000000ce")
assert.Nil(t, err)
stream := &amqpStream{data: data, message: new(amqpMessage)}
m := stream.message
ok, complete := amqp.amqpMessageParser(stream)
if !ok {
t.Errorf("Parsing returned error")
}
if !complete {
t.Errorf("Message should be complete")
}
assert.Equal(t, "exchange.declare", m.method)
assert.Equal(t, "logs_topic", m.fields["exchange"])
assert.Equal(t, "logs_topic", m.request)
assert.Equal(t, true, m.fields["durable"])
assert.Equal(t, false, m.fields["passive"])
assert.Equal(t, false, m.fields["no-wait"])
assert.Equal(t, "topic", m.fields["exchange-type"])
_, exists := m.fields["arguments"].(common.MapStr)
if exists {
t.Errorf("Arguments field should not be present")
}
}
开发者ID:ruflin,项目名称:beats,代码行数:34,代码来源:amqp_test.go
示例9: TestAmqp_ConnectionCloseNoError
func TestAmqp_ConnectionCloseNoError(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
amqp.hideConnectionInformation = false
data, err := hex.DecodeString("01000000000012000a003200c8076b74687862616900000000ce")
assert.Nil(t, err)
data2, err := hex.DecodeString("01000000000004000a0033ce")
assert.Nil(t, err)
tcptuple := testTCPTuple()
req := protos.Packet{Payload: data}
private := protos.ProtocolData(new(amqpPrivateData))
private = amqp.Parse(&req, tcptuple, 0, private)
req = protos.Packet{Payload: data2}
amqp.Parse(&req, tcptuple, 1, private)
trans := expectTransaction(t, amqp)
assert.Equal(t, "connection.close", trans["method"])
assert.Equal(t, "amqp", trans["type"])
assert.Equal(t, common.OK_STATUS, trans["status"])
assert.Nil(t, trans["notes"])
fields, ok := trans["amqp"].(common.MapStr)
assert.True(t, ok)
code, ok := fields["reply-code"].(uint16)
assert.True(t, ok)
assert.Equal(t, uint16(200), code)
}
开发者ID:ruflin,项目名称:beats,代码行数:33,代码来源:amqp_test.go
示例10: TestUseType
func TestUseType(t *testing.T) {
if testing.Short() {
t.Skip("Skipping in short mode. Requires Kafka")
}
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"kafka"})
}
id := strconv.Itoa(rand.New(rand.NewSource(int64(time.Now().Nanosecond()))).Int())
logType := fmt.Sprintf("log-type-%s", id)
kafka := newTestKafkaOutput(t, "", true)
event := common.MapStr{
"@timestamp": common.Time(time.Now()),
"host": "test-host",
"type": logType,
"message": id,
}
if err := kafka.PublishEvent(nil, testOptions, event); err != nil {
t.Fatal(err)
}
messages := testReadFromKafkaTopic(t, logType, 1, 5*time.Second)
if assert.Len(t, messages, 1) {
msg := messages[0]
logp.Debug("kafka", "%s: %s", msg.Key, msg.Value)
assert.Contains(t, string(msg.Value), id)
}
}
开发者ID:ChongFeng,项目名称:beats,代码行数:29,代码来源:kafka_integration_test.go
示例11: TestMissingFields
func TestMissingFields(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"*"})
}
yml := []map[string]interface{}{
map[string]interface{}{
"include_fields": map[string]interface{}{
"equals": map[string]string{
"type": "process",
},
},
},
}
config := filter.FilterPluginConfig{}
for _, rule := range yml {
c := map[string]common.Config{}
for name, ruleYml := range rule {
ruleConfig, err := common.NewConfigFrom(ruleYml)
assert.Nil(t, err)
c[name] = *ruleConfig
}
config = append(config, c)
}
_, err := filter.New(config)
assert.NotNil(t, err)
}
开发者ID:McStork,项目名称:beats,代码行数:34,代码来源:filter_test.go
示例12: 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 := newTestClient(server.URL)
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:troyconder,项目名称:beats,代码行数:34,代码来源:api_mock_test.go
示例13: 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)
client := newTestClient(server.URL)
params := map[string]string{
"refresh": "true",
}
_, resp, err := client.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:troyconder,项目名称:beats,代码行数:29,代码来源:api_mock_test.go
示例14: 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:jarpy,项目名称:beats,代码行数:35,代码来源:mysql_test.go
示例15: BenchmarkIcmpProcessICMPv4
func BenchmarkIcmpProcessICMPv4(b *testing.B) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"icmp", "icmpdetailed"})
}
results := &publish.ChanTransactions{make(chan common.MapStr, 10)}
icmp, err := New(true, results, common.NewConfig())
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(nil, icmpRequestData, packetRequestData)
icmp.ProcessICMPv4(nil, icmpResponseData, packetResponseData)
client := icmp.results.(*publish.ChanTransactions)
<-client.Channel
}
}
开发者ID:ChongFeng,项目名称:beats,代码行数:28,代码来源:icmp_test.go
示例16: TestAmqp_QueueDeclaration
func TestAmqp_QueueDeclaration(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
data, err := hex.DecodeString("0100010000001a0032000a00000e5468697320697" +
"3206120544553541800000000ce")
assert.Nil(t, err)
stream := &amqpStream{data: data, message: new(amqpMessage)}
m := stream.message
ok, complete := amqp.amqpMessageParser(stream)
if !ok {
t.Errorf("Parsing returned error")
}
if !complete {
t.Errorf("Message should be complete")
}
assert.Equal(t, "This is a TEST", m.fields["queue"])
assert.Equal(t, false, m.fields["passive"])
assert.Equal(t, false, m.fields["durable"])
assert.Equal(t, false, m.fields["exclusive"])
assert.Equal(t, true, m.fields["auto-delete"])
assert.Equal(t, true, m.fields["no-wait"])
_, exists := m.fields["arguments"].(common.MapStr)
if exists {
t.Errorf("Arguments field should not be present")
}
}
开发者ID:ruflin,项目名称:beats,代码行数:33,代码来源:amqp_test.go
示例17: TestAmqp_ChannelCloseErrorMethod
func TestAmqp_ChannelCloseErrorMethod(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
data, err := hex.DecodeString("0100010000009000140028019685505245434f4e444" +
"954494f4e5f4641494c4544202d20696e6571756976616c656e74206172672027617574" +
"6f5f64656c6574652720666f722065786368616e676520277465737445786368616e676" +
"52720696e2076686f737420272f273a207265636569766564202774727565272062757" +
"42063757272656e74206973202766616c7365270028000ace")
assert.Nil(t, err)
data2, err := hex.DecodeString("0100010000000400280033ce")
assert.Nil(t, err)
tcptuple := testTCPTuple()
req := protos.Packet{Payload: data}
private := protos.ProtocolData(new(amqpPrivateData))
private = amqp.Parse(&req, tcptuple, 0, private)
req = protos.Packet{Payload: data2}
amqp.Parse(&req, tcptuple, 1, private)
trans := expectTransaction(t, amqp)
assert.Equal(t, "channel.close", trans["method"])
assert.Equal(t, "amqp", trans["type"])
assert.Equal(t, common.ERROR_STATUS, trans["status"])
assert.Nil(t, trans["notes"])
}
开发者ID:ruflin,项目名称:beats,代码行数:30,代码来源:amqp_test.go
示例18: 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:ruflin,项目名称:beats,代码行数:30,代码来源:pgsql_test.go
示例19: TestAmqp_MultipleBodyFrames
func TestAmqp_MultipleBodyFrames(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"amqp", "amqpdetailed"})
}
amqp := amqpModForTests()
amqp.sendRequest = true
data, err := hex.DecodeString("0100010000000e003c00280000000568656c6c6f00ce" +
"02000100000021003c0000000000000000002a80400a746578742f706c61696e00000000" +
"56a22873ce030001000000202a2a2a68656c6c6f2049206c696b6520746f207075626c69" +
"736820626967206dce")
assert.Nil(t, err)
data2, err := hex.DecodeString("0300010000000a657373616765732a2a2ace")
assert.Nil(t, err)
tcptuple := testTCPTuple()
req := protos.Packet{Payload: data}
private := protos.ProtocolData(new(amqpPrivateData))
private = amqp.Parse(&req, tcptuple, 0, private)
req = protos.Packet{Payload: data2}
amqp.Parse(&req, tcptuple, 0, private)
trans := expectTransaction(t, amqp)
assert.Equal(t, "basic.publish", trans["method"])
assert.Equal(t, "***hello I like to publish big messages***", trans["request"])
}
开发者ID:ruflin,项目名称:beats,代码行数:25,代码来源:amqp_test.go
示例20: testAsyncLBFailSendWithoutActiveConnection
func testAsyncLBFailSendWithoutActiveConnection(t *testing.T, events []eventInfo) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"*"})
}
errFail := errors.New("fail connect")
mode, _ := NewAsyncConnectionMode(
[]AsyncProtocolClient{
&mockClient{
connected: false,
close: closeOK,
connect: alwaysFailConnect(errFail),
},
&mockClient{
connected: false,
close: closeOK,
connect: alwaysFailConnect(errFail),
},
},
false,
2,
100*time.Millisecond,
100*time.Millisecond,
1*time.Second,
)
testMode(t, mode, testNoOpts, events, signals(false), nil)
}
开发者ID:sweco-semtne,项目名称:beats,代码行数:26,代码来源:balance_async_test.go
注:本文中的github.com/elastic/beats/libbeat/logp.LogInit函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论