CCockrum commited on
Commit
b8028cf
·
verified ·
1 Parent(s): 7477320

Update log.py

Browse files
Files changed (1) hide show
  1. log.py +7 -38
log.py CHANGED
@@ -1,40 +1,9 @@
1
- # utils.py
2
 
3
- import os
4
- import requests
5
- from log import logger
6
 
7
-
8
- def create_directories(path):
9
- os.makedirs(path, exist_ok=True)
10
-
11
-
12
- def remove_directory_contents(path):
13
- if not os.path.exists(path):
14
- return
15
- for filename in os.listdir(path):
16
- file_path = os.path.join(path, filename)
17
- if os.path.isfile(file_path):
18
- os.remove(file_path)
19
- elif os.path.isdir(file_path):
20
- import shutil
21
- shutil.rmtree(file_path)
22
-
23
-
24
- def download_manager(url, output_dir):
25
- filename = os.path.basename(url)
26
- output_path = os.path.join(output_dir, filename)
27
- if os.path.exists(output_path):
28
- return output_path
29
-
30
- logger.info(f"Downloading: {filename}")
31
- os.makedirs(os.path.dirname(output_path), exist_ok=True) # Ensure directory exists
32
-
33
- with requests.get(url, stream=True) as r:
34
- r.raise_for_status()
35
- with open(output_path, 'wb') as f:
36
- for chunk in r.iter_content(chunk_size=8192):
37
- f.write(chunk)
38
-
39
- logger.info(f"Downloaded: {filename}")
40
- return output_path
 
1
+ # log.py
2
 
3
+ import logging
 
 
4
 
5
+ logger = logging.getLogger("audio_splitter")
6
+ logger.setLevel(logging.INFO)
7
+ ch = logging.StreamHandler()
8
+ ch.setFormatter(logging.Formatter("[%(levelname)s] %(message)s"))
9
+ logger.addHandler(ch)