Syntax: -vmodule=recordio=2,file=1,gfs*=3
(value string)
| 301 | |
| 302 | // Syntax: -vmodule=recordio=2,file=1,gfs*=3 |
| 303 | func (*moduleSpec) Set(value string) error { |
| 304 | filter := make([]modulePat, 0, 2) |
| 305 | for _, pat := range strings.Split(value, ",") { |
| 306 | if pat == "" { |
| 307 | // Empty strings such as from a trailing comma can be ignored. |
| 308 | continue |
| 309 | } |
| 310 | patLev := strings.Split(pat, "=") |
| 311 | if len(patLev) != 2 || patLev[0] == "" || patLev[1] == "" { |
| 312 | return errVmoduleSyntax |
| 313 | } |
| 314 | pattern := patLev[0] |
| 315 | v, err := strconv.Atoi(patLev[1]) |
| 316 | if err != nil { |
| 317 | return errors.New("syntax error: expect comma-separated list of filename=N") |
| 318 | } |
| 319 | if v < 0 { |
| 320 | return errors.New("negative value for vmodule level") |
| 321 | } |
| 322 | if v == 0 { |
| 323 | continue // Ignore. It's harmless but no point in paying the overhead. |
| 324 | } |
| 325 | // TODO: check syntax of filter? |
| 326 | filter = append(filter, modulePat{pattern: pattern, level: Level(v), literal: isLiteral(pattern)}) |
| 327 | } |
| 328 | logging.mu.Lock() |
| 329 | defer logging.mu.Unlock() |
| 330 | logging.setVState(logging.verbosity, filter, true) |
| 331 | return nil |
| 332 | } |
| 333 | |
| 334 | // isLiteral reports whether the pattern is a literal string, that is, has no metacharacters |
| 335 | // that require filepath.Match to be called to match the pattern. |