github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/glog/convenient_api.go (about)

     1  // Copyright 2013 <chaishushan{AT}gmail.com>. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package glog
     6  
     7  const (
     8  	LogThreshold_info    = int(infoLog)
     9  	LogThreshold_warning = int(warningLog)
    10  	LogThreshold_error   = int(errorLog)
    11  	LogThreshold_fatal   = int(fatalLog)
    12  	LogThreshold_Max     = int(numSeverity)
    13  )
    14  
    15  func GetToStderr() bool {
    16  	return logging.toStderr
    17  }
    18  func SetToStderr(enabled bool) {
    19  	logging.toStderr = enabled
    20  }
    21  
    22  func GetAlsoToStderr() bool {
    23  	return logging.alsoToStderr
    24  }
    25  func SetAlsoToStderr(enabled bool) {
    26  	logging.alsoToStderr = enabled
    27  }
    28  
    29  func GetStderrThreshold() int {
    30  	return int(logging.stderrThreshold)
    31  }
    32  func SetStderrThreshold(threshold int) {
    33  	if threshold >= 0 && threshold < int(numSeverity) {
    34  		logging.stderrThreshold = severity(threshold)
    35  	}
    36  }
    37  
    38  func GetLogDir() string {
    39  	if len(logDirs) > 0 {
    40  		return logDirs[0]
    41  	} else {
    42  		return ""
    43  	}
    44  }
    45  func SetLogDir(dir string) {
    46  	if len(logDirs) > 0 {
    47  		logDirs[0] = dir
    48  	} else {
    49  		logDirs = []string{dir}
    50  	}
    51  }