-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
refactor: use sophisticated logger #1129
Draft
jase88
wants to merge
12
commits into
CycloneDX:main
Choose a base branch
from
jase88:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+135
−78
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bb10d8a
feat: add logger
jase88 e7d6794
feat: add logger
jase88 3f600e3
feat: add default log level const
jase88 532f853
feat: adjust string interpolation via parameters
jase88 91b4b48
fix: wrong placeholder
jase88 ecaf9a3
feat: add child logger
jase88 40d10c8
Merge branch 'main' into main
jase88 f6b09ce
Merge branch 'main' into main
jkowalleck b5af86b
fix: writing to stderr
jase88 c3abef5
Merge remote-tracking branch 'origin/main'
jase88 49af968
fix: raise required node version
jase88 8f58bca
fix: disable timestamps
jase88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*! | ||
This file is part of CycloneDX generator for NPM projects. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
SPDX-License-Identifier: Apache-2.0 | ||
Copyright (c) OWASP Foundation. All Rights Reserved. | ||
*/ | ||
|
||
import { type BaseLogger, type Level, type LevelWithSilent, type LoggerExtras, pino } from 'pino' | ||
|
||
const logLevels: Level[] = ['debug', 'error', 'fatal', 'warn', 'info', 'trace'] as const | ||
export const verbosityLevels: LevelWithSilent[] = [...logLevels, 'silent'] as const | ||
|
||
export type Logger = BaseLogger & LoggerExtras<{ | ||
level: LevelWithSilent | ||
name: string | ||
transport: { options: { colorize: boolean, ignore: string }, target: string } | ||
}> | ||
|
||
export type VerbosityLevel = LevelWithSilent | ||
|
||
export const createLogger: (verbosityLevel: VerbosityLevel) => Logger = (verbosityLevel: VerbosityLevel) => pino({ | ||
name: 'cyclonedx-node-npm', | ||
level: verbosityLevel, | ||
timestamp: false, | ||
transport: { | ||
target: 'pino-pretty', | ||
options: { | ||
colorize: true, | ||
ignore: 'pid,name,hostname', | ||
destination: 2 | ||
} | ||
} | ||
}) | ||
|
||
export const defaultLogLevel: VerbosityLevel = 'warn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
node:
notation, this might not work on node14.0 -- which is a supported branch.will add additional CI tests and have it tested
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.
test run including node 14.0.0
https://github.com/CycloneDX/cyclonedx-node-npm/actions/runs/7114640707/job/19369091011?pr=1129
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.
tests with node14.0.0 do not complete due to a transitive dependency that is not installable.