Example #1
0
File: flags.go Project: ainoya/fune
package flags

import (
	"flag"
	"github.com/ainoya/fune/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
	"strings"
)

var (
	plog = capnslog.NewPackageLogger("github.com/ainoya/fune/pkg", "flags")
)

// ActionNames implements the flag.Value interface.
type ActionNames []string

// Set implements the function of flag.Value interface.
// It splits by a comma separeted value to array of string.
func (actionNames *ActionNames) Set(s string) error {
	strs := strings.Split(s, ",")
	*actionNames = strs
	return nil
}

// Set implements the function of flag.Value interface.
// It joins an array of strings to a comma separeted value(string).
func (actionNames *ActionNames) String() string {
	all := make([]string, len(*actionNames))
	for i, u := range *actionNames {
		all[i] = u
	}
	return strings.Join(all, ",")
Example #2
0
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package osutil

import (
	"os"
	"strings"

	"github.com/ainoya/fune/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

var (
	plog = capnslog.NewPackageLogger("github.com/coreos/etcd/pkg", "osutil")
)

func Unsetenv(key string) error {
	envs := os.Environ()
	os.Clearenv()
	for _, e := range envs {
		strs := strings.SplitN(e, "=", 2)
		if strs[0] == key {
			continue
		}
		if err := os.Setenv(strs[0], strs[1]); err != nil {
			return err
		}
	}
	return nil
Example #3
0
File: agent.go Project: ainoya/fune
package funeagent

import (
	"github.com/ainoya/fune/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
	"github.com/ainoya/fune/actions"
	"github.com/ainoya/fune/emitter"
	"github.com/ainoya/fune/listener"
)

var plog = capnslog.NewPackageLogger("github.com/ainoya/fune", "funeagent")

// FuneAgent is the agent implementation
type FuneAgent struct {
	cfg *AgentConfig

	stop   chan struct{}
	done   chan struct{}
	errorc chan error

	listener listener.Listener
	emitter  *emitter.Emitter
}

// NewAgent creates a new FuneAgent from the supplied configuration. The
// configuration is considered static for the lifetime of the FuneAgent.
func NewAgent(cfg *AgentConfig) (*FuneAgent, error) {
	agent := &FuneAgent{
		cfg:    cfg,
		errorc: make(chan error, 1),
	}
Example #4
0
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
	"flag"
	oldlog "log"

	"github.com/ainoya/fune/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

var logLevel = capnslog.INFO
var log = capnslog.NewPackageLogger("github.com/coreos/pkg/capnslog/cmd", "main")
var dlog = capnslog.NewPackageLogger("github.com/coreos/pkg/capnslog/cmd", "dolly")

func init() {
	flag.Var(&logLevel, "log-level", "Global log level.")
}

func main() {
	rl := capnslog.MustRepoLogger("github.com/coreos/pkg/capnslog/cmd")

	// We can parse the log level configs from the command line
	flag.Parse()
	if flag.NArg() > 1 {
		cfg, err := rl.ParseLogLevelConfig(flag.Arg(1))
		if err != nil {
			log.Fatal(err)