aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeongJae Park <sj38.park@gmail.com>2024-03-17 10:24:24 -0700
committerSeongJae Park <sj38.park@gmail.com>2024-03-17 10:24:24 -0700
commitfa890b00d1dab301a5bcc13e45f7d747b94ecc39 (patch)
treed2a6c9c9c2c7367217a3697fec0590a795d02288
parent807a63b49f5059b487ed1c3bac709c82b30eb9da (diff)
downloaddamo-fa890b00d1dab301a5bcc13e45f7d747b94ecc39.tar.gz
_damon: Use _damo_fs.debug_print_ops() insted of a global variable
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r--_damo_fs.py6
-rw-r--r--_damon.py5
2 files changed, 3 insertions, 8 deletions
diff --git a/_damo_fs.py b/_damo_fs.py
index 47f055fb..075449a6 100644
--- a/_damo_fs.py
+++ b/_damo_fs.py
@@ -2,8 +2,6 @@
import os
-import _damon
-
debug_do_print = False
def debug_print_ops(do_print):
@@ -17,7 +15,7 @@ def read_file(filepath):
content = f.read()
except Exception as e:
return None, 'reading %s failed (%s)' % (filepath, e)
- if _damon.pr_debug_log or debug_do_print:
+ if debug_do_print:
print('read \'%s\': \'%s\'' % (filepath, content.strip()))
return content, None
@@ -37,7 +35,7 @@ def read_files(root):
Returns None if success error string otherwise
'''
def write_file(filepath, content):
- if _damon.pr_debug_log or debug_do_print:
+ if debug_do_print:
print('write \'%s\' to \'%s\'' % (content.strip(), filepath))
try:
with open(filepath, 'w') as f:
diff --git a/_damon.py b/_damon.py
index 912a99e0..93e16cb8 100644
--- a/_damon.py
+++ b/_damon.py
@@ -1004,8 +1004,6 @@ features = ['record', # was in DAMON patchset, but not merged in mainline
_damon_fs = None
-pr_debug_log = False
-
def ensure_root_permission():
if os.geteuid() != 0:
print('Run as root')
@@ -1090,9 +1088,8 @@ def initialize(damon_interface, debug_damon,
if not _damon_fs.supported():
return 'DAMON interface (%s) not supported' % damon_interface
- global pr_debug_log
if debug_damon:
- pr_debug_log = True
+ _damo_fs.debug_print_ops(True)
if load_feature_supports:
err = read_feature_supports_file()