mirror of
https://github.com/onyx-and-iris/gignore.git
synced 2025-04-07 22:23:52 +01:00
-loglevel now string flag
upd README, CHANGELOG
This commit is contained in:
parent
38b0611e4e
commit
6aac14b9ed
@ -5,7 +5,14 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
# [0.3.0] - 2024-14-03
|
# [0.4.0] - 2025-04-05
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `-loglevel` flag is now of type string. It accepts any one of trace, debug, info, warn, error, fatal or panic.
|
||||||
|
- It defaults to warn.
|
||||||
|
|
||||||
|
# [0.3.0] - 2025-14-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
22
README.md
22
README.md
@ -56,6 +56,28 @@ You may set an environment variable `GIGNORE_TEMPLATE_DIR` to avoid passing the
|
|||||||
|
|
||||||
If a template is requested but not found in the custom directory then the gitignoreio registry will act as a fallback.
|
If a template is requested but not found in the custom directory then the gitignoreio registry will act as a fallback.
|
||||||
|
|
||||||
|
## Logging
|
||||||
|
|
||||||
|
The `-loglevel` flag allows you to control the verbosity of the application's logging output.
|
||||||
|
|
||||||
|
Acceptable values for this flag are:
|
||||||
|
|
||||||
|
- `trace`
|
||||||
|
- `debug`
|
||||||
|
- `info`
|
||||||
|
- `warn`
|
||||||
|
- `error`
|
||||||
|
- `fatal`
|
||||||
|
- `panic`
|
||||||
|
|
||||||
|
For example, to set the log level to `debug`, you can use:
|
||||||
|
|
||||||
|
```
|
||||||
|
vbantxt -s=streamname -log-level=debug "bus[0].eq.on=1 bus[1].gain=-12.8"
|
||||||
|
```
|
||||||
|
|
||||||
|
The default log level is `warn` if the flag is not specified.
|
||||||
|
|
||||||
## Special Thanks
|
## Special Thanks
|
||||||
|
|
||||||
[gitignore.io][gitignoreio] For providing such a useful .gitignore service
|
[gitignore.io][gitignoreio] For providing such a useful .gitignore service
|
||||||
|
@ -5,12 +5,17 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"os"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/gignore"
|
"github.com/onyx-and-iris/gignore"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func exit(err error) {
|
||||||
|
_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
w := flag.CommandLine.Output()
|
w := flag.CommandLine.Output()
|
||||||
@ -30,7 +35,7 @@ func main() {
|
|||||||
var (
|
var (
|
||||||
list bool
|
list bool
|
||||||
templateDir string
|
templateDir string
|
||||||
loglevel int
|
loglevel string
|
||||||
)
|
)
|
||||||
|
|
||||||
flag.BoolVar(&list, "list", false, "list available templates")
|
flag.BoolVar(&list, "list", false, "list available templates")
|
||||||
@ -41,19 +46,22 @@ func main() {
|
|||||||
getEnv("GIGNORE_TEMPLATE_DIR", "gitignoreio"),
|
getEnv("GIGNORE_TEMPLATE_DIR", "gitignoreio"),
|
||||||
"directory containing .gitignore templates",
|
"directory containing .gitignore templates",
|
||||||
)
|
)
|
||||||
flag.IntVar(&loglevel, "loglevel", int(log.WarnLevel), "log level")
|
flag.StringVar(&loglevel, "loglevel", "warn", "log level")
|
||||||
flag.IntVar(&loglevel, "l", int(log.WarnLevel), "log level (shorthand)")
|
flag.StringVar(&loglevel, "l", "warn", "log level (shorthand)")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if slices.Contains(log.AllLevels, log.Level(loglevel)) {
|
level, err := log.ParseLevel(loglevel)
|
||||||
log.SetLevel(log.Level(loglevel))
|
if err != nil {
|
||||||
|
exit(fmt.Errorf("invalid log level: %s", loglevel))
|
||||||
}
|
}
|
||||||
|
log.SetLevel(level)
|
||||||
|
|
||||||
client := gignore.New(gignore.WithTemplateDirectory(templateDir))
|
client := gignore.New(gignore.WithTemplateDirectory(templateDir))
|
||||||
|
|
||||||
if list {
|
if list {
|
||||||
if err := listTemplates(client); err != nil {
|
if err := listTemplates(client); err != nil {
|
||||||
log.Fatalf("failed to list templates: %v", err)
|
exit(fmt.Errorf("failed to list templates: %v", err))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -67,7 +75,7 @@ func main() {
|
|||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
err := client.Create(arg)
|
err := client.Create(arg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to create .gitignore file: %v", err)
|
exit(fmt.Errorf("failed to create .gitignore file: %v", err))
|
||||||
}
|
}
|
||||||
fmt.Printf("√ created %s .gitignore file\n", arg)
|
fmt.Printf("√ created %s .gitignore file\n", arg)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user