Spaces:
Running
Running
Update app2.py
Browse files
app2.py
CHANGED
@@ -28,20 +28,30 @@ import tarfile
|
|
28 |
import gzip
|
29 |
import math
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
# Conditional imports for document processing
|
32 |
try:
|
33 |
from PyPDF2 import PdfReader
|
34 |
PDF_SUPPORT = True
|
35 |
except ImportError:
|
36 |
PDF_SUPPORT = False
|
37 |
-
logger.warning("PyPDF2 not installed. PDF file processing will be limited.")
|
38 |
|
39 |
try:
|
40 |
from docx import Document
|
41 |
DOCX_SUPPORT = True
|
42 |
except ImportError:
|
43 |
DOCX_SUPPORT = False
|
44 |
-
logger.warning("python-docx not installed. DOCX file processing will be limited.")
|
45 |
|
46 |
try:
|
47 |
from pyth.plugins.rtf15.reader import Rtf15Reader
|
|
|
28 |
import gzip
|
29 |
import math
|
30 |
|
31 |
+
# Setup enhanced logging with more detailed formatting
|
32 |
+
logging.basicConfig(
|
33 |
+
level=logging.INFO,
|
34 |
+
format='%(asctime)s - %(levelname)s - [%(filename)s:%(lineno)d] - %(message)s',
|
35 |
+
handlers=[
|
36 |
+
logging.StreamHandler(),
|
37 |
+
logging.FileHandler('app.log', encoding='utf-8')
|
38 |
+
])
|
39 |
+
logger = logging.getLogger(__name__) # logger is now defined here
|
40 |
+
|
41 |
# Conditional imports for document processing
|
42 |
try:
|
43 |
from PyPDF2 import PdfReader
|
44 |
PDF_SUPPORT = True
|
45 |
except ImportError:
|
46 |
PDF_SUPPORT = False
|
47 |
+
logger.warning("PyPDF2 not installed. PDF file processing will be limited.") # logger is available
|
48 |
|
49 |
try:
|
50 |
from docx import Document
|
51 |
DOCX_SUPPORT = True
|
52 |
except ImportError:
|
53 |
DOCX_SUPPORT = False
|
54 |
+
logger.warning("python-docx not installed. DOCX file processing will be limited.") # logger is available
|
55 |
|
56 |
try:
|
57 |
from pyth.plugins.rtf15.reader import Rtf15Reader
|