Skip to content

Commit

Permalink
feat(cmd): add verbosity flag for logging
Browse files Browse the repository at this point in the history
This commit adds a new feature to the `cmd` module. It introduces a new `verbosity` flag for logging, which allows the user to control the level of log output. The `verbosity` flag is implemented using the `clap_verbosity_flag` crate.

The `verbosity` flag is defined as a `Verbosity<InfoLevel>` field in the `Cmd` struct. It is then used to initialize the logging level in the `run` method of the `Cmd` trait. The logging level is determined based on the value of the `verbosity` flag, and the corresponding `tracing::Level` is set for the logging framework.

If the logging level is less than `DEBUG`, the logging configuration is set to exclude file names, line numbers, targets, and timestamps. Otherwise, the logging configuration includes all these details. The logging level is then used to initialize the logging framework.

This change allows users to control the verbosity of log output, making it easier to debug and troubleshoot issues.
  • Loading branch information
liblaf committed Dec 1, 2023
1 parent 3beac6c commit d700ff3
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check
run: |-
run: |
function checks() {
(gh pr checks ${{ github.event.pull_request.html_url }} || true) |
grep --invert-match ${{ github.run_id }}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: CI/CD
name: CI

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
build:
Expand All @@ -20,7 +18,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Install GNU Softwares
uses: liblaf/install-action@main
uses: liblaf/template/.github/actions/install@main
with:
brew: coreutils gnu-sed make
choco: gnuwin32-coreutils.install make sed
Expand All @@ -44,6 +42,7 @@ jobs:

release:
name: Create GitHub Release
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
releases-created: ${{ steps.release.outputs.releases_created }}
Expand Down
36 changes: 26 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
ci:
autofix_commit_msg: |-
autofix_commit_msg: |
ci(pre-commit): auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autoupdate_commit_msg: |-
autoupdate_commit_msg: |
ci(pre-commit): pre-commit autoupdate
skip:
- cargo-check
- cargo-clippy
- poetry-lock

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [--fix]
args:
- --fix
- id: ruff-format
- repo: https://github.com/cmhughes/latexindent.pl
rev: V3.23.3
hooks:
- id: latexindent
- id: latexindent-conda
- repo: https://github.com/commitizen-tools/commitizen
rev: 3.12.0
hooks:
Expand All @@ -27,12 +30,16 @@ repos:
rev: v17.0.6
hooks:
- id: clang-format
types_or: [c, c++, cuda]
types_or:
- c
- c++
- cuda
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
stages: [pre-commit]
stages:
- pre-commit
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand Down Expand Up @@ -69,7 +76,9 @@ repos:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
args: [--without-hashes, --without-urls]
args:
- --without-hashes
- --without-urls
- id: poetry-install
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.7.0-4
Expand All @@ -81,23 +90,30 @@ repos:
- --indent=2
- --case-indent
- --space-redirects
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.0.0
hooks:
- id: cspell
- repo: local
hooks:
- id: cargo-check
name: cargo check
entry: cargo check
language: rust
types: [rust]
types:
- rust
pass_filenames: false
- id: cargo-clippy
name: cargo clippy
entry: cargo clippy
language: rust
types: [rust]
types:
- rust
pass_filenames: false
- id: cargo-fmt
name: cargo fmt
entry: cargo fmt
language: rust
types: [rust]
types:
- rust
pass_filenames: false
Loading

0 comments on commit d700ff3

Please sign in to comment.