-
Notifications
You must be signed in to change notification settings - Fork 247
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
feat(log): support verbosing logging #61
base: master
Are you sure you want to change the base?
Conversation
/cc @niieani @tterranigma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the variable name and revert the formatting of the files so it is consistent. I presume you used some auto-formatter on the file, hence it rolled together the if/then
s?
Thanks.
lib/util/log.sh
Outdated
if [[ ! -z ${__oo__loggers["$logger"]} ]] | ||
then | ||
${__oo__loggers["$logger"]} "$@" | ||
if [[ ! -z ${__oo__loggers["$logger"]} ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repository uses syntax with a new line, so I'd prefer to keep it consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
lib/util/log.sh
Outdated
for logger in "${loggers[@]}" | ||
do | ||
loggers=(${loggerList//;/ }) | ||
for logger in "${loggers[@]}"; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repository uses syntax with a new line, so I'd prefer to keep it consistent.
lib/util/log.sh
Outdated
then | ||
if [[ -z $logged ]] || [[ ${__oo__logDisabledFilter["$scope"]} == true ]] | ||
then | ||
if [[ ! -z "${__oo__logScopeOutputs["$scope"]}" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repository uses syntax with a new line, so I'd prefer to keep it consistent.
lib/util/log.sh
Outdated
@@ -6,6 +6,9 @@ declare -Ag __oo__logScopeOutputs | |||
declare -Ag __oo__logDisabledFilter | |||
declare -Ag __oo__loggers | |||
|
|||
# Controls verbosity of the script output and logging. | |||
VERBOSE="${VERBOSE:-5}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use something like __oo__verbosity
for the variable name, VERBOSE
can conflict with a user-space variable of the same name.
Ideally, we'd set this variable with some configuration function, but I can accept this as a temporary workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the variable VERBOSE
is for user to set.
Just like the example, before or after users import util/log
, they can set/change the VERBOSE
level by themselves to determine which log will be displayed
VERBOSE=2
Log::AddOutput test/verbose DEBUG
Log "this log will be displayed"
V=2 Log "this log will be displayed"
VERBOSE=1
V=2 Log "this log will not be displayed"
ping @niieani And
|
Example