Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Adds a valid plugin log path on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jcooklin committed Feb 1, 2016
1 parent 62d03b6 commit d7b4897
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion control/plugin/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"fmt"
"log"
"os"
"runtime"
"time"

"github.com/intelsdi-x/snap/control/plugin/cpolicy"
Expand Down Expand Up @@ -252,7 +253,11 @@ func NewSessionState(pluginArgsMsg string, plugin Plugin, meta *PluginMeta) (*Se
truncOrAppend := os.O_TRUNC // truncate log file explicitly given by user
// Empty or /tmp means use default tmp log (needs to be removed post-aAtruncOrAppendpha)
if pluginArg.PluginLogPath == "" || pluginArg.PluginLogPath == "/tmp" {
pluginArg.PluginLogPath = "/tmp/snap_plugin.log"
if runtime.GOOS == "windows" {
pluginArg.PluginLogPath = `c:\TEMP\snap_plugin.log`
} else {
pluginArg.PluginLogPath = "/tmp/snap_plugin.log"
}
truncOrAppend = os.O_APPEND
}
lf, err := os.OpenFile(pluginArg.PluginLogPath, os.O_WRONLY|os.O_CREATE|truncOrAppend, 0666)
Expand Down
7 changes: 6 additions & 1 deletion control/plugin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -231,9 +232,13 @@ type pluginManager struct {
}

func newPluginManager(opts ...pluginManagerOpt) *pluginManager {
logPath := "/tmp"
if runtime.GOOS == "windows" {
logPath = `c:\temp`
}
p := &pluginManager{
loadedPlugins: newLoadedPlugins(),
logPath: "/tmp",
logPath: logPath,
pluginConfig: newPluginConfig(),
}

Expand Down

0 comments on commit d7b4897

Please sign in to comment.