-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename spider to scraper and change the logging instance
- Loading branch information
Showing
4 changed files
with
32 additions
and
19 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ | |
class Context(BaseModel): | ||
logger: logging.Logger | ||
config: EnvConfig | ||
|
||
class Config: | ||
arbitrary_types_allowed = True |
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 |
---|---|---|
@@ -1,19 +1,24 @@ | ||
import logging | ||
|
||
# Configure the logger | ||
# Configure the logger for the entire module | ||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.DEBUG) | ||
formatter = logging.Formatter( | ||
"%(asctime)s - %(name)s - %(levelname)s - %(message)s", "%Y-%m-%d %H:%M:%S" | ||
) | ||
|
||
# Configure file handler | ||
file_handler = logging.FileHandler("spidy.log") | ||
file_handler.setFormatter(formatter) | ||
logger.addHandler(file_handler) | ||
def new_logger(name): | ||
name = name | ||
|
||
# Optionally, configure console handler | ||
console_handler = logging.StreamHandler() | ||
console_handler.setFormatter(formatter) | ||
logger.addHandler(console_handler) | ||
# Configure the logger | ||
logger = logging.getLogger(name) | ||
logger.setLevel(logging.DEBUG) | ||
formatter = logging.Formatter( | ||
"%(asctime)s - %(name)s - %(levelname)s - %(message)s", "%Y-%m-%d %H:%M:%S" | ||
) | ||
|
||
# Configure file handler | ||
file_handler = logging.FileHandler(f"{name}.log") | ||
file_handler.setFormatter(formatter) | ||
logger.addHandler(file_handler) | ||
|
||
# Optionally, configure console handler | ||
console_handler = logging.StreamHandler() | ||
console_handler.setFormatter(formatter) | ||
logger.addHandler(console_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