本文整理汇总了Golang中github.com/jcelliott/lumber.NewConsoleLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang NewConsoleLogger函数的具体用法?Golang NewConsoleLogger怎么用?Golang NewConsoleLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewConsoleLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddFlags
// AddFlags adds cli flags to logvac
func AddFlags(cmd *cobra.Command) {
// collectors
cmd.Flags().StringVarP(&ListenHttp, "listen-http", "a", ListenHttp, "API listen address (same endpoint for http log collection)")
cmd.Flags().StringVarP(&ListenUdp, "listen-udp", "u", ListenUdp, "UDP log collection endpoint")
cmd.Flags().StringVarP(&ListenTcp, "listen-tcp", "t", ListenTcp, "TCP log collection endpoint")
// drains
cmd.Flags().StringVarP(&PubAddress, "pub-address", "p", PubAddress, "Log publisher (mist) address (\"mist://127.0.0.1:1445\")")
cmd.Flags().StringVarP(&PubAuth, "pub-auth", "P", PubAuth, "Log publisher (mist) auth token")
cmd.Flags().StringVarP(&DbAddress, "db-address", "d", DbAddress, "Log storage address")
// authenticator
cmd.PersistentFlags().StringVarP(&AuthAddress, "auth-address", "A", AuthAddress, "Address or file location of authentication db. ('boltdb:///var/db/logvac.bolt' or 'postgresql://127.0.0.1')")
// other
cmd.Flags().StringVarP(&CorsAllow, "cors-allow", "C", CorsAllow, "Sets the 'Access-Control-Allow-Origin' header")
cmd.Flags().StringVarP(&LogKeep, "log-keep", "k", LogKeep, "Age or number of logs to keep per type '{\"app\":\"2w\", \"deploy\": 10}' (int or X(m)in, (h)our, (d)ay, (w)eek, (y)ear)")
cmd.Flags().StringVarP(&LogLevel, "log-level", "l", LogLevel, "Level at which to log")
cmd.Flags().StringVarP(&LogType, "log-type", "L", LogType, "Default type to apply to incoming logs (commonly used: app|deploy)")
cmd.Flags().StringVarP(&Token, "token", "T", Token, "Administrative token to add/remove 'X-USER-TOKEN's used to pub/sub via http")
cmd.Flags().BoolVarP(&Server, "server", "s", Server, "Run as server")
cmd.Flags().BoolVarP(&Insecure, "insecure", "i", Insecure, "Don't use TLS (used for testing)")
cmd.Flags().BoolVarP(&Version, "version", "v", Version, "Print version info and exit")
Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))
}
示例2: TestSetService
func TestSetService(t *testing.T) {
config.DatabaseConnection = "scribble:///tmp/scribbleTest"
config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))
// Backend = &database.ScribbleDatabase{}
database.Init()
if err := database.SetService(&testService1); err != nil {
t.Errorf("Failed to SET service - %v", err)
}
service, err := ioutil.ReadFile("/tmp/scribbleTest/services/tcp-192_168_0_15-80.json")
if err != nil {
t.Error(err)
}
jService, err := toJson(testService1)
if err != nil {
t.Error(err)
}
if string(service) != string(jService) {
t.Errorf("Read service differs from written service")
}
}
示例3: initialize
// manually configure and start internals
func initialize() {
config.Insecure = true
config.L2Connect = "none://"
config.ApiListen = "127.0.0.1:1634"
config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))
config.LogLevel = "FATAL"
}
示例4: New
// New creates a new scribble database at the desired directory location, and
// returns a *Driver to then use for interacting with the database
func New(dir string, options *Options) (*Driver, error) {
//
dir = filepath.Clean(dir)
// create default options
opts := Options{}
// if options are passed in, use those
if options != nil {
opts = *options
}
// if no logger is provided, create a default
if opts.Logger == nil {
opts.Logger = lumber.NewConsoleLogger(lumber.INFO)
}
//
driver := Driver{
dir: dir,
mutexes: make(map[string]sync.Mutex),
log: opts.Logger,
}
// if the database already exists, just use it
if _, err := os.Stat(dir); err == nil {
opts.Logger.Info("Using '%s' (database already exists)\n", dir)
return &driver, nil
}
// if the database doesn't exist create it
opts.Logger.Info("Creating scribble database at '%s'...\n", dir)
return &driver, os.MkdirAll(dir, 0755)
}
示例5: startLogvac
func startLogvac(ccmd *cobra.Command, args []string) error {
// initialize logger
lumber.Level(lumber.LvlInt(config.LogLevel)) // for clients using lumber too
config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))
// initialize logvac
logvac.Init()
// setup authenticator
err := authenticator.Init()
if err != nil {
return fmt.Errorf("Authenticator failed to initialize - %v", err)
}
// initialize drains
err = drain.Init()
if err != nil {
return fmt.Errorf("Drain failed to initialize - %v", err)
}
// initializes collectors
err = collector.Init()
if err != nil {
return fmt.Errorf("Collector failed to initialize - %v", err)
}
err = api.Start(collector.CollectHandler)
if err != nil {
return fmt.Errorf("Api failed to initialize - %v", err)
}
return nil
}
示例6: initialize
// manually configure and start internals
func initialize() {
config.ListenHttp = "127.0.0.1:4234"
config.ListenTcp = "127.0.0.1:4235"
config.ListenUdp = "127.0.0.1:4234"
config.DbAddress = "boltdb:///tmp/syslogTest/logvac.bolt"
config.AuthAddress = ""
config.Insecure = true
config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))
// initialize logvac
logvac.Init()
// setup authenticator
err := authenticator.Init()
if err != nil {
config.Log.Fatal("Authenticator failed to initialize - %v", err)
os.Exit(1)
}
// initialize drains
err = drain.Init()
if err != nil {
config.Log.Fatal("Drain failed to initialize - %v", err)
os.Exit(1)
}
// initializes collectors
err = collector.Init()
if err != nil {
config.Log.Fatal("Collector failed to initialize - %v", err)
os.Exit(1)
}
}
示例7: startShaman
func startShaman(ccmd *cobra.Command, args []string) error {
config.Log = lumber.NewConsoleLogger(lumber.LvlInt(config.LogLevel))
// initialize cache
err := cache.Initialize()
if err != nil {
config.Log.Fatal(err.Error())
return err
}
// make channel for errors
errors := make(chan error)
go func() {
errors <- api.Start()
}()
go func() {
errors <- server.Start()
}()
// break if any of them return an error (blocks exit)
if err := <-errors; err != nil {
config.Log.Fatal(err.Error())
}
return err
}
示例8: initialize
func initialize() {
ifIptables, err := exec.Command("iptables", "-S").CombinedOutput()
if err != nil {
fmt.Printf("Failed to run iptables - %s%v\n", ifIptables, err.Error())
skip = true
}
ifIpvsadm, err := exec.Command("ipvsadm", "--version").CombinedOutput()
if err != nil {
fmt.Printf("Failed to run ipvsadm - %s%v\n", ifIpvsadm, err.Error())
skip = true
}
config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))
if !skip {
// todo: find more friendly way to clear crufty rules only
err = exec.Command("iptables", "-F", "portal").Run()
if err != nil {
fmt.Printf("Failed to clear iptables - %v\n", err.Error())
os.Exit(1)
}
err = exec.Command("ipvsadm", "-C").Run()
if err != nil {
fmt.Printf("Failed to clear ipvsadm - %v\n", err.Error())
os.Exit(1)
}
balance.Init()
}
}
示例9: initialize
// manually configure and start internals
func initialize() error {
var err error
drain.CleanFreq = 1
config.LogKeep = `{"app": "1s", "deploy":0}`
config.LogKeep = `{"app": "1s", "deploy":0, "a":"1m", "aa":"1h", "b":"1d", "c":"1w", "d":"1y", "e":"1"}`
config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))
// initialize logvac
logvac.Init()
// initialize archiver
// Doing broke db
config.DbAddress = "[email protected]#$%^&*()"
drain.Init()
// Doing file db
config.DbAddress = "file:///tmp/boltdbTest/logvac.bolt"
drain.Init()
drain.Archiver.(*drain.BoltArchive).Close()
// Doing no db
config.DbAddress = "/tmp/boltdbTest/logvac.bolt"
drain.Init()
drain.Archiver.(*drain.BoltArchive).Close()
// Doing bolt db
config.DbAddress = "boltdb:///tmp/boltdbTest/logvac.bolt"
drain.Init()
return err
}
示例10: mistInitialize
// manually configure and start internals
func mistInitialize() error {
var err error
drain.CleanFreq = 1
config.LogKeep = `{"app": "1s", "deploy":0}`
config.LogKeep = `{"app": "1s", "deploy":0, "a":"1m", "aa":"1h", "b":"1d", "c":"1w", "d":"1y", "e":"1"}`
config.Log = lumber.NewConsoleLogger(lumber.LvlInt("ERROR"))
config.DbAddress = "boltdb:///tmp/boltdbTest/logvac.bolt"
server.StartTCP(PubAddress, nil)
// initialize logvac
logvac.Init()
// initialize publisher
// Doing broke publisher
config.PubAddress = "[email protected]#$%^&*()"
drain.Init()
drain.Archiver.(*drain.BoltArchive).Close()
// Doing schemeless publisher
config.PubAddress = "127.0.0.1:2445"
drain.Init()
drain.Archiver.(*drain.BoltArchive).Close()
drain.Publisher.(*drain.Mist).Close()
// Doing real publisher
config.PubAddress = "mist://127.0.0.1:2445"
err = drain.Init()
return err
}
示例11: init
func init() {
rand.Seed(time.Now().Unix())
animalsText, _ := ioutil.ReadFile(path.Join(RuntimeArgs.SourcePath, "static/text/animals"))
animals = strings.Split(string(animalsText), ",")
adjectivesText, _ := ioutil.ReadFile(path.Join(RuntimeArgs.SourcePath, "static/text/adjectives"))
adjectives = strings.Split(string(adjectivesText), "\n")
logger = lumber.NewConsoleLogger(lumber.INFO)
}
示例12: Parse
func Parse(configFile string) {
c := map[string]string{}
bytes, err := ioutil.ReadFile(configFile)
if err != nil {
Log.Error("unable to read config file: %v\n", err)
}
err = yaml.Unmarshal(bytes, &c)
if err != nil {
Log.Error("err parsing config file: %v\n", err)
Log.Error("falling back to default values")
}
Log = lumber.NewConsoleLogger(lumber.LvlInt(c["log_level"]))
if c["ssh_listen_address"] != "" {
SshListenAddress = c["ssh_listen_address"]
}
if c["http_listen_address"] != "" {
HttpListenAddress = c["http_listen_address"]
}
if c["key_path"] != "" {
KeyPath = c["key_path"]
}
if c["repo_type"] != "" {
RepoType = c["repo_type"]
}
if c["repo_location"] != "" {
RepoLocation = c["repo_location"]
}
if c["key_auth_type"] != "" {
KeyAuthType = c["key_auth_type"]
}
if c["key_auth_location"] != "" {
KeyAuthLocation = c["key_auth_location"]
}
if c["repo_type"] != "" {
RepoType = c["repo_type"]
}
if c["repo_location"] != "" {
RepoLocation = c["repo_location"]
}
if c["repo_type"] != "" {
RepoType = c["repo_type"]
}
if c["repo_location"] != "" {
RepoLocation = c["repo_location"]
}
if c["repo_type"] != "" {
RepoType = c["repo_type"]
}
if c["repo_location"] != "" {
RepoLocation = c["repo_location"]
}
if c["token"] != "" {
Token = c["token"]
}
}
示例13: TestMain
func TestMain(m *testing.M) {
shamanClear()
// manually configure
config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))
// run tests
rtn := m.Run()
os.Exit(rtn)
}
示例14: TestMain
func TestMain(m *testing.M) {
// manually configure
// config.Log = lumber.NewConsoleLogger(lumber.LvlInt("trace"))
config.Log = lumber.NewConsoleLogger(lumber.LvlInt("FATAL"))
// run tests
rtn := m.Run()
os.Exit(rtn)
}
示例15: init
// init
func init() {
// create a console logger
Console = lumber.NewConsoleLogger(lumber.INFO)
// create a file logger
if Log, err = lumber.NewAppendLogger(Root + "/nanobox.log"); err != nil {
Fatal("[config/log] lumber.NewAppendLogger() failed", err.Error())
}
}