-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add logs to Dapr Workflows #645
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7a92ebf
Adding loggerOptions
shivamkm07 80fb6f4
Adding logs to Dapr workflows
shivamkm07 47334bc
linter fixes
shivamkm07 d7d9219
fix unit test failure
shivamkm07 e0044b1
Moving logger to dapr-ext-workflow
shivamkm07 d38d639
Merge branch 'main' into add_logger
shivamkm07 80e12bf
fix build failure
shivamkm07 ff578e4
linter issues
shivamkm07 ebde05a
Adding Logger Class
shivamkm07 a342f73
linter fixes
shivamkm07 c7660b9
Updating logs
shivamkm07 8eaba3c
merge main
shivamkm07 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
Empty file.
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,50 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Copyright 2023 The Dapr Authors | ||
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. | ||
""" | ||
|
||
from typing import Union | ||
import logging | ||
|
||
|
||
class LoggerOptions: | ||
def __init__( | ||
self, | ||
log_level: Union[str, None] = None, | ||
log_handler: Union[logging.Handler, None] = None, | ||
log_formatter: Union[logging.Formatter, None] = None, | ||
): | ||
# Set default log level to INFO if none is provided | ||
if log_level is None: | ||
log_level = logging.INFO | ||
# Add a default log handler if none is provided | ||
if log_handler is None: | ||
log_handler = logging.StreamHandler() | ||
# Set a default log formatter if none is provided | ||
if log_formatter is None: | ||
log_formatter = logging.Formatter( | ||
fmt="%(asctime)s.%(msecs)03d %(name)s %(levelname)s: %(message)s", | ||
datefmt='%Y-%m-%d %H:%M:%S') | ||
self.log_level = log_level | ||
self.log_handler = log_handler | ||
self.log_formatter = log_formatter | ||
|
||
def get_logger( | ||
self, | ||
name: str) -> logging.Logger: | ||
logger = logging.Logger(name) | ||
log_handler = self.log_handler | ||
log_handler.setLevel(self.log_level) | ||
log_handler.setFormatter(self.log_formatter) | ||
logger.handlers.append(log_handler) | ||
return logger |
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
Oops, something went wrong.
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.
This can be the Logger class with init having the
name
parameter as required and rest as optional as they are now.Then in one call
logger = Logger(name)
this is satisfied, is there a requirement that the logger must be initialized with the DaprWorkflowClient as seen in that file?@berndverst thoughts?
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.
@mukundansundar Added logger class. Please review