Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: sink level #13

Merged
merged 9 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
#

BasedOnStyle: Google
BreakStringLiterals: true
NamespaceIndentation: All
BreakBeforeBinaryOperators: NonAssignment
AlignOperands: false
AlignOperands: AlignAfterOperator
DerivePointerAlignment: false
PointerAlignment: Right
BinPackArguments: true
BinPackParameters: true
BinPackArguments: false
BinPackParameters: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
IncludeBlocks: Preserve
InsertBraces: true
InsertTrailingCommas: Wrapped
SortIncludes: CaseSensitive
QualifierAlignment: Custom
QualifierOrder: ['inline', 'static', 'constexpr', 'const', 'volatile', 'type', 'restrict']
ReferenceAlignment: Right
ReflowComments: true
#RemoveSemicolon: true
InsertNewlineAtEOF: true
47 changes: 44 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,50 @@
#

---
Checks: '-*,clang-analyzer-*,clang-diagnostic-*,readability-*,modernize-*,-modernize-use-trailing-return-type,boost-*,bugprone-*,cppcoreguidelines-*,google-*,hicpp-*,performance-*,readability-*,-google-readability-namespace-comments,-readability-inconsistent-declaration-parameter-name,-readability-braces-around-statements,-hicpp-signed-bitwise,-google-runtime-references,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-readability-magic-numbers,-hicpp-explicit-conversions,-hicpp-uppercase-literal-suffix,-readability-uppercase-literal-suffix,-hicpp-no-array-decay,-hicpp-special-member-functions,-bugprone-narrowing-conversions,-modernize-use-nodiscard,-google-readability-braces-around-statements,-hicpp-braces-around-statements,-bugprone-suspicious-semicolon,-readability-named-parameter,-hicpp-named-parameter,-readability-identifier-naming'
WarningsAsErrors: 'modernize-*,cppcoreguidelines-*,boost-*,google-build-using-namespace,readability-else-after-return,google-readability-todo'
AnalyzeTemporaryDtors: false
Checks: "-*,
clang-analyzer-*, \
clang-diagnostic-*, \
-clang-diagnostic-missing-template-arg-list-after-template-kw, \
modernize-*, \
-modernize-use-nodiscard, \
-modernize-use-trailing-return-type, \
boost-*, \
bugprone-*, \
-bugprone-narrowing-conversions, \
-bugprone-suspicious-semicolon, \
cppcoreguidelines-*, \
-cppcoreguidelines-rvalue-reference-param-not-moved, \
-cppcoreguidelines-avoid-magic-numbers, \
-cppcoreguidelines-pro-bounds-array-to-pointer-decay, \
google-*, \
-google-readability-namespace-comments, \
-google-readability-braces-around-statements, \
-google-runtime-references, \
hicpp-*, \
-hicpp-explicit-conversions, \
-hicpp-uppercase-literal-suffix, \
-hicpp-signed-bitwise, \
-hicpp-no-array-decay, \
-hicpp-special-member-functions, \
-hicpp-braces-around-statements, \
-hicpp-named-parameter, \
performance-*, \
readability-*, \
-readability-magic-numbers, \
-readability-named-parameter, \
-readability-identifier-naming, \
-readability-uppercase-literal-suffix, \
-readability-inconsistent-declaration-parameter-name, \
-readability-braces-around-statements"
WarningsAsErrors: "modernize-*, \
cppcoreguidelines-*, \
boost-*, \
performance-*, \
google-build-using-namespace, \
readability-else-after-return, \
readability-container-contains, \
google-readability-todo"
HeaderFilterRegex: '\(hpp|h|pb\.h)'
FormatStyle: .clang-format
User: user
CheckOptions:
Expand Down
8 changes: 4 additions & 4 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ fi

# check clang-format binary
CLANG_FORMAT_ENABLED=1
CLANG_FORMAT=$(which clang-format-15)
CLANG_FORMAT=$(which clang-format-19)
if [ -z "${CLANG_FORMAT}" ]; then
CLANG_FORMAT=$(which clang-format)
if [ -z "${CLANG_FORMAT}" ]; then
echo "Command clang-format is not found" >&2
echo "Please, install clang-format version 15 to enable checkup C++-files formatting over git pre-commit hook" >&2
echo "Please, install clang-format version 19 to enable checkup C++-files formatting over git pre-commit hook" >&2
CLANG_FORMAT_ENABLED=0
fi
fi
Expand All @@ -29,8 +29,8 @@ fi
if [ $CLANG_FORMAT_ENABLED ]; then
CLANG_FORMAT_VERSION=$($CLANG_FORMAT --version | sed -r "s/.*version ([[:digit:]]+).*/\1/")

if [ "$CLANG_FORMAT_VERSION" != "15" ]; then
echo "Please, install clang-format version 15 to enable checkup C++-files formatting over git pre-commit hook" >&2
if [ "$CLANG_FORMAT_VERSION" != "19" ]; then
echo "Please, install clang-format version 19 to enable checkup C++-files formatting over git pre-commit hook" >&2
CLANG_FORMAT_ENABLED=0
fi
fi
Expand Down
11 changes: 11 additions & 0 deletions .github/aux/github_venv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright Quadrivium LLC
# All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#

GITHUB_ENV="${GITHUB_ENV:?}"
export VIRTUAL_ENV="${1:?venv path not set}"
export PATH="$VIRTUAL_ENV/bin:$PATH"
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> "$GITHUB_ENV"
echo "PATH=$PATH" >> "$GITHUB_ENV"
18 changes: 9 additions & 9 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
name: checkout
Expand All @@ -29,20 +29,20 @@ jobs:
run: |
set -e
sudo apt-get update || true
sudo apt-get install -y ninja-build gcovr gcc-13 g++-13 clang-15 clang++-15 llvm-15
sudo apt-get install -y ninja-build gcovr gcc-13 g++-13 llvm-18 clang-18 clang++-18 clang-tidy-18 clang-format-18

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 90
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 999
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 999
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-15/bin/clang-15 999
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 999
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 999
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 999
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-18/bin/clang-18 999
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 999
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 90
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-13 90

sudo python3 -m pip install --upgrade pip
sudo python3 -m pip install scikit-build
sudo python3 -m pip install cmake==3.25 requests gitpython gcovr pyyaml
# sudo python3 -m pip install --upgrade pip
# sudo python3 -m pip install scikit-build
# sudo python3 -m pip install cmake==3.25 requests gitpython gcovr pyyaml
- name: run checks
run: |
#!/bin/bash
Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/compilers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macOS-14]
os: [ubuntu-latest, macOS-latest]
compiler: [{
"cc": "gcc",
"cxx": "g++"
Expand All @@ -30,7 +30,7 @@ jobs:
"cxx": "clang++"
}]
exclude:
- os: macOS-14
- os: macOS-latest
compiler:
cc: gcc
steps:
Expand All @@ -41,6 +41,9 @@ jobs:
clean: true
fetch-depth: 1

- name: venv
run: python3 -m venv --upgrade-deps ~/venv && .github/aux/github_venv.sh $_

- name: install dependencies
run: |
set -e
Expand All @@ -49,20 +52,20 @@ jobs:
brew install ninja
else
sudo apt-get update || true
sudo apt-get install -y ninja-build gcc-13 g++-13 clang-15 clang++-15
sudo apt-get install -y ninja-build gcovr gcc-13 g++-13 clang-18 clang++-18 clang-tidy-18 clang-format-18

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 90
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 999
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 999
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-15/bin/clang-15 999
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 999
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 999
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 999
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-18/bin/clang-18 999
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 999
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 90
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-13 90
fi

sudo python3 -m pip install --upgrade pip
sudo python3 -m pip install scikit-build
sudo python3 -m pip install cmake==3.25 requests gitpython gcovr pyyaml
pip3 install scikit-build
pip3 install cmake==3.25 requests gitpython gcovr pyyaml

- name: cmake
env:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
jobs:
coverage:
name: "codecov"
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v1
Expand All @@ -30,20 +30,20 @@ jobs:
run: |
set -e
sudo apt-get update || true
sudo apt-get install -y ninja-build gcovr gcc-13 g++-13 clang-15 clang++-15
sudo apt-get install -y ninja-build gcovr gcc-13 g++-13 clang-18 clang++-18 clang-tidy-18 clang-format-18

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 90
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 999
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 999
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-15/bin/clang-15 999
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 999
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-18 999
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 999
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-18/bin/clang-18 999
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 999
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 90
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-13 90

sudo python3 -m pip install --upgrade pip
sudo python3 -m pip install scikit-build
sudo python3 -m pip install cmake==3.25 requests gitpython gcovr pyyaml
# sudo python3 -m pip install --upgrade pip
# sudo python3 -m pip install scikit-build
# sudo python3 -m pip install cmake==3.25 requests gitpython gcovr pyyaml

- name: "cmake"
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: "Undefined Behavior Sanitizer"
sanitizer: UBSAN
name: "${{ matrix.options.name }}"
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v1
Expand All @@ -52,8 +52,8 @@ jobs:
set -e
sudo apt-get update || true
sudo apt-get install -y ninja-build
sudo python3 -m pip install --upgrade pip
sudo pip3 install cmake requests gitpython gcovr pyyaml
# sudo python3 -m pip install --upgrade pip
# sudo pip3 install cmake requests gitpython gcovr pyyaml

- name: cmake
env:
Expand Down
103 changes: 46 additions & 57 deletions example/01-simple/logger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,53 @@
# SPDX-License-Identifier: Apache-2.0
#

sinks:
- name: colored_stdout
type: console
stream: stdout
color: true
thread: name
capacity: 64
max_message_length: 120
buffer: 131072
latency: 100
- name: simple_stderr
type: console
stream: stderr
color: false
thread: name
capacity: 64
max_message_length: 120
buffer: 131072
latency: 100
- name: file
type: file
path: /tmp/solalog_example.log
thread: name
capacity: 2048
buffer: 4194304
latency: 1000
- name: syslog
type: syslog
ident: solalog_example
thread: name
capacity: 2048
buffer: 4194304
latency: 1000
- name: sink_to_everywhere
type: multisink
sinks:
sinks: # List of sink configurations
- name: colored_stdout # Unique name of the sink
type: console # Sink type: 'console' means output to the standard output or error stream
stream: stdout # Output stream type (stdout or stderr)
color: true # Whether to insert escape sequences for colored output
thread: name # Thread differentiation method: 'name' for named threads, 'id' for enumerated threads, 'none' for no print (default)
capacity: 64 # Maximum number of buffered messages; affects memory usage
max_message_length: 120 # Maximum length of a single message; extra characters are dropped, affects memory usage
buffer: 131072 # Maximum buffered data size in bytes before forcing a flush
latency: 100 # Maximum delay in milliseconds before forcing a buffer flush; 0 means immediate flushing (default)
level: trace # Maximum log level this sink accepts (from trace and above)
- name: simple_stderr # Unique name of the sink
type: console # Sink type: 'console' means output to the standard output or error stream
stream: stderr # Output stream type (stdout or stderr)
color: false # Whether to insert escape sequences for colored output
thread: name # Thread differentiation method: 'name' for named threads, 'id' for enumerated threads, 'none' for no print (default)
capacity: 64 # Maximum number of buffered messages; affects memory usage
max_message_length: 120 # Maximum length of a single message; extra characters are dropped, affects memory usage
buffer: 131072 # Maximum buffered data size in bytes before forcing a flush
latency: 100 # Maximum delay in milliseconds before forcing a buffer flush
level: info # Maximum log level this sink accepts (from info and above)
- name: file # Unique name of the sink
type: file # Sink type: 'file' means output to a file
path: /tmp/solalog_example.log # Path to the output file
thread: name # Thread differentiation method: 'name' for named threads, 'id' for enumerated threads, 'none' for no print (default)
capacity: 2048 # Maximum number of buffered messages; affects memory usage
buffer: 4194304 # Maximum buffered data size in bytes before forcing a flush
latency: 1000 # Maximum delay in milliseconds before forcing a buffer flush; 0 means immediate flushing (default)
- name: syslog # Unique name of the sink
type: syslog # Sink type: 'syslog' means messages are sent to the system's syslog daemon
ident: solalog_example # Identifier for the syslog channel
thread: name # Thread differentiation method: 'name' for named threads, 'id' for enumerated threads, 'none' for no print (default)
capacity: 2048 # Maximum number of buffered messages; affects memory usage
buffer: 4194304 # Maximum buffered data size in bytes before forcing a flush
latency: 1000 # Maximum delay in milliseconds before forcing a buffer flush; 0 means immediate flushing (default)
- name: sink_to_everywhere # Unique name of the sink
type: multisink # Sink type: 'multisink' means messages are broadcasted to the specified underlying sinks
sinks: # List of underlying sinks by name
- file
- colored_stdout
- simple_stderr
- syslog
groups:
- name: main
sink: sink_to_everywhere
level: trace
children:
- name: blockchain
- name: consensus
level: debug
children:
- name: grandpa
level: info
- name: babe
children:
- name: block_executor
level: trace
- name: runtime
level: off
children:
- name: transaction
sink: file
level: debug
groups: # List of group configurations
- name: main # Unique name of the group
sink: sink_to_everywhere # Name of the sink used for output from loggers in this group; must be defined for a root group
level: trace # Maximum log level this group accepts; must be defined for a root group
is_fallback: true # If true, this group is the default fallback group; only one group can be marked as fallback
children: # Nested groups; these groups inherit properties from the parent
- name: example_group
- name: another_group
Loading
Loading