Пример #1
0
// Set is part of the flag.Value interface.
func (s *SeverityFlag) Set(value string) error {
	out, err := log.SeverityFromString(value)
	if err != nil {
		return err
	}
	s.S = out
	return nil
}
Пример #2
0
func (c *ProxyController) updateLogSeverity(w http.ResponseWriter, r *http.Request, params map[string]string) (interface{}, error) {
	s, err := log.SeverityFromString(r.Form.Get("severity"))
	if err != nil {
		return nil, formatError(err)
	}
	c.ng.SetLogSeverity(s)
	return scroll.Response{"message": fmt.Sprintf("Severity has been updated to %v", s)}, nil
}
Пример #3
0
func (c *Client) GetLogSeverity() (log.Severity, error) {
	data, err := c.Get(c.endpoint("log", "severity"), url.Values{})
	if err != nil {
		return -1, err
	}
	var sev *SeverityResponse
	if err := json.Unmarshal(data, &sev); err != nil {
		return -1, err
	}
	return log.SeverityFromString(sev.Severity)
}