Skip to content

Commit 709aff0

Browse files
committed
refactor, third part
2 parents 73e135d + 8161215 commit 709aff0

File tree

14 files changed

+314
-226
lines changed

14 files changed

+314
-226
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ celerybeat-schedule
8383
# virtualenv
8484
venv/
8585
ENV/
86+
env*/
8687

8788
# Spyder project settings
8889
.spyderproject

CHANGES.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ Changes
44
0.0.2 (2019-XX-XX)
55
------------------
66

7-
* FIX: Implementation of truncate did rely on the assumption that the current working directory of the file system process would not change. This was risky.
7+
* FEATURE: New flag ``-j`` for JSON-formatted log output
8+
* FEATURE: New field ``command`` allowed in XML configuration files for filtering for command strings with regular expressions
9+
* FEATURE: All fields in ``include`` and ``exclude`` tags, e.g. ``extension`` or ``uid``, become optional / implicit and can be omitted.
10+
* FEATURE: (UNTESTED) Mac OS X support. Test framework still relies on Linux.
11+
* FIX: Several implementations of FUSE calls such as truncate did rely on the assumption that the current working directory of the file system process would not change. This was risky. LoggedFS-python does also NOT change the current working directory anymore on its own.
812
* Code cleanup
913

1014
0.0.1 (2019-04-11)

README.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ CAVEATS
6464
UTIME_OMIT WILL NOT BE HONORED. THERE WAS A `PULL REQUEST`_ TO FIX THIS,
6565
WHICH HAS BEEN REJECTED. ALTERNATIVE APPROACHES ARE BEING RESEARCHED.
6666
* THE FILESYSTEM IS CURRENTLY **ONLY** BEING DEVELOPED FOR AND TESTED ON **LINUX**.
67-
ANYONE INTERESTED IN ADDING MAC OS X AND/OR BSD SUPPORT?
67+
ANYONE INTERESTED IN CONFIRMING MAC OS X AND/OR ADDING BSD SUPPORT?
6868

6969
.. _CUSTOM BUG-FIXED VERSION OF FUSEPY: https://github.com/s-m-e/fusepy
7070
.. _PULL REQUEST: https://github.com/fusepy/fusepy/pull/79
@@ -88,7 +88,7 @@ From GitHub:
8888
**Supports Python 3.{4,5,6,7}.**
8989

9090
**Supports Linux.**
91-
Support for MAC OS X and BSD requires a minor change only, but has yet not been added: Access to the system log is currently being achieved through ``logging.handlers.SysLogHandler(address = '/dev/log')``, a Linux-only solution.
91+
Support for MAC OS X is implemented but has yet not been tested.
9292

9393
.. _Python Package Index: https://pypi.org/
9494

@@ -112,9 +112,7 @@ To stop recording, just unmount as usual:
112112
Configuration
113113
=============
114114

115-
LoggedFS-python can use an XML configuration file if you want it to log
116-
operations only for certain files, for certain users, or for certain operations.
117-
The format is fully compatible with LoggedFS' original format.
115+
LoggedFS-python can use an XML configuration file if you want it to log operations only for certain files, for certain users, or for certain operations. LoggedFS-python is fully compatible with configuration files in LoggedFS' original format. Yet it can also handle additional fields (e.g. the ``command`` field).
118116

119117
Here is a sample configuration file :
120118

@@ -124,12 +122,12 @@ Here is a sample configuration file :
124122
125123
<loggedFS logEnabled="true" printProcessName="true">
126124
<includes>
127-
<include extension=".*" uid="*" action=".*" retname=".*"/>
125+
<include extension=".*" uid="*" action=".*" retname=".*" command=".*"/>
128126
</includes>
129127
<excludes>
130-
<exclude extension=".*\.bak$" uid="*" action=".*" retname="SUCCESS"/>
131-
<exclude extension=".*" uid="1000" action=".*" retname="FAILURE"/>
132-
<exclude extension=".*" uid="*" action="getattr" retname=".*"/>
128+
<exclude extension=".*\.bak$" uid="*" action=".*" retname="SUCCESS" command=".*"/>
129+
<exclude extension=".*" uid="1000" action=".*" retname="FAILURE" command=".*"/>
130+
<exclude extension=".*" uid="*" action="getattr" retname=".*" command=".*"/>
133131
</excludes>
134132
</loggedFS>
135133

makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ destroy_parentfs:
8585
python3 -c 'import tests; tests.lib.quick_cli_destroy_parentfs()'
8686
destroy_childfs:
8787
python3 -c 'import tests; tests.lib.quick_cli_destroy_childfs()'
88+
destroy_force:
89+
-sudo fusermount -u tests/test_mount/test_child
90+
-sudo umount tests/test_mount
8891

8992
test:
9093
make test_posix

src/loggedfs/cli.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,19 @@
6262
)
6363
@click.option(
6464
'-l',
65-
# type = click.File(mode = 'a'),
6665
type = click.Path(file_okay = True, dir_okay = False, resolve_path = True),
6766
help = ('Use the "log-file" to write logs to.')
6867
)
68+
@click.option(
69+
'-j', '--json',
70+
is_flag = True,
71+
help = 'Format output as JSON instead of traditional loggedfs format.'
72+
)
6973
@click.argument(
7074
'directory',
7175
type = click.Path(exists = True, file_okay = False, dir_okay = True, resolve_path = True)
7276
)
73-
def cli_entry(f, p, c, s, l, directory):
77+
def cli_entry(f, p, c, s, l, json, directory):
7478
"""LoggedFS-python is a transparent fuse-filesystem which allows to log
7579
every operations that happens in the backend filesystem. Logs can be written
7680
to syslog, to a file, or to the standard output. LoggedFS comes with an XML
@@ -82,7 +86,7 @@ def cli_entry(f, p, c, s, l, directory):
8286

8387
loggedfs_factory(
8488
directory,
85-
**__process_config__(c, l, s, f, p)
89+
**__process_config__(c, l, s, f, p, json)
8690
)
8791

8892

@@ -91,7 +95,8 @@ def __process_config__(
9195
log_file,
9296
log_syslog_off,
9397
fuse_foreground_bool,
94-
fuse_allowother_bool
98+
fuse_allowother_bool,
99+
log_json
95100
):
96101

97102
if config_fh is not None:
@@ -105,13 +110,14 @@ def __process_config__(
105110
config_dict = parse_filters(config_xml_str)
106111

107112
return {
108-
'log_includes': config_dict['includes'],
109-
'log_excludes': config_dict['excludes'],
113+
'log_includes': config_dict['log_includes'],
114+
'log_excludes': config_dict['log_excludes'],
115+
'log_enabled': config_dict['log_enabled'],
116+
'log_printprocessname': config_dict['log_printprocessname'],
110117
'log_file': log_file,
111118
'log_syslog': not log_syslog_off,
112119
'log_configmsg': 'LoggedFS-python using configuration file %s' % config_file,
113-
'log_enabled': config_dict['@logEnabled'],
114-
'log_printprocessname': config_dict['@printProcessName'],
120+
'log_json': log_json,
115121
'fuse_foreground_bool': fuse_foreground_bool,
116122
'fuse_allowother_bool': fuse_allowother_bool
117123
}

0 commit comments

Comments
 (0)