Skip to content

Commit

Permalink
mini 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MingliangT committed Nov 26, 2018
1 parent 43bc80f commit f0113a5
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 458 deletions.
17 changes: 0 additions & 17 deletions cmd/instrument-php/main.go

This file was deleted.

4 changes: 1 addition & 3 deletions cmd/replayer/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package main

import (
_ "github.com/v2pro/koala/gateway/gw4libc"
"github.com/v2pro/koala/envarg"
"github.com/v2pro/plz/witch"
_ "github.com/v2pro/koala/gateway/gw4libc"
)

func init() {
envarg.SetupLogging()
witch.Start(":8318")
}

func main() {
Expand Down
33 changes: 16 additions & 17 deletions envarg/envarg.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,24 @@ var gcGlobalStatusTimeout = 5 * time.Second
func init() {
initInboundAddr()
initOutboundAddr()
initOutboundBypassPort()
initSutAddr()
logFile = GetenvFromC("KOALA_LOG_FILE")
if logFile == "" {
logFile = "STDOUT"
}
initLogLevel()
logFormat = GetenvFromC("KOALA_LOG_FORMAT")
if logFormat == "" {
logFormat = "HumanReadableFormat"
}
initOutboundBypassPort()
initGcGlobalStatusTimeout()
initLog()

countlog.Trace("event!koala.envarg_init",
"logLevel", logLevel,
"logFile", logFile,
"logFormat", logFormat,
"logLevel", logLevel, "logFile", logFile, "logFormat", logFormat,
"inboundReadTimeout", inboundReadTimeout,
"outboundBypassPort", outboundBypassPort,
"isReplaying", IsReplaying(),
"isRecording", IsRecording(),
"isTracing", IsTracing())
"isReplaying", IsReplaying(), "isRecording", IsRecording(), "isTracing", IsTracing())
}

func initLogLevel() {
func initLog() {
logFile = GetenvFromC("KOALA_LOG_FILE")
if logFile == "" {
logFile = "STDOUT"
}

logLevelStr := strings.ToUpper(GetenvFromC("KOALA_LOG_LEVEL"))
switch logLevelStr {
case "TRACE":
Expand All @@ -64,6 +58,11 @@ func initLogLevel() {
case "FATAL":
logLevel = countlog.LevelFatal
}

logFormat = GetenvFromC("KOALA_LOG_FORMAT")
if logFormat == "" {
logFormat = "HumanReadableFormat"
}
}

func initInboundAddr() {
Expand Down
2 changes: 1 addition & 1 deletion gateway/gw4libc/version.c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
char* library_version = { "KOALA-VERSION: 2.4.4" };
char* library_version = { "KOALA-VERSION: 3.0.0" };
27 changes: 5 additions & 22 deletions sut/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package sut
import (
"bytes"
"context"
"github.com/v2pro/koala/envarg"
"github.com/v2pro/koala/recording"
"github.com/v2pro/koala/replaying"
"github.com/v2pro/koala/trace"
"github.com/v2pro/plz/countlog"
"net"
"os"
"strings"
"sync"
"time"
"unsafe"

"github.com/v2pro/koala/envarg"
"github.com/v2pro/koala/recording"
"github.com/v2pro/koala/replaying"
"github.com/v2pro/plz/countlog"
)

// InboundRequestPrefix is used to recognize php-fpm FCGI_BEGIN_REQUEST packet.
Expand Down Expand Up @@ -318,20 +318,11 @@ func (thread *Thread) OnOpeningFile(fileName string, flags int) string {
return ""
}
originalFileName := fileName
shouldTrace := thread.replayingSession.ShouldTraceFile(fileName)
fileName = thread.tryMockFile(fileName)
if shouldTrace {
fileName = thread.instrumentFile(fileName)
}
fileName = thread.tryRedirectFile(fileName)
shouldTrace = thread.replayingSession.ShouldTraceFile(fileName)
fileName = thread.tryMockFile(fileName)
if shouldTrace {
fileName = thread.instrumentFile(fileName)
}
countlog.Trace("event!sut.opening_file",
"threadID", thread.threadID,
"shouldTrace", shouldTrace,
"originalFile", originalFileName,
"finalFile", fileName)
return fileName
Expand All @@ -350,14 +341,6 @@ func (thread *Thread) tryRedirectFile(fileName string) string {
return fileName
}

func (thread *Thread) instrumentFile(fileName string) string {
instrumentedFileName := trace.InstrumentFile(fileName)
if instrumentedFileName != "" {
return instrumentedFileName
}
return fileName
}

func (thread *Thread) tryMockFile(fileName string) string {
if thread.replayingSession.MockFiles != nil {
mockContent := thread.replayingSession.MockFiles[fileName]
Expand Down
Loading

0 comments on commit f0113a5

Please sign in to comment.