Skip to content

Commit d91e346

Browse files
committed
0.0.2 release
2 parents 3017deb + 6eef19d commit d91e346

File tree

16 files changed

+747
-457
lines changed

16 files changed

+747
-457
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changes
22
=======
33

4+
0.0.2 (2019-04-23)
5+
------------------
6+
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.
12+
* Code cleanup
13+
414
0.0.1 (2019-04-11)
515
------------------
616

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

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444

4545
# Bump version HERE!
46-
_version_ = '0.0.1'
46+
_version_ = '0.0.2'
4747

4848

4949
# List all versions of Python which are supported

src/loggedfs/cli.py

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@
2929
# IMPORT
3030
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3131

32-
from collections import OrderedDict
32+
import click
3333

3434
from .core import loggedfs_factory
35-
36-
import click
37-
import xmltodict
35+
from .filter import parse_filters
3836

3937

4038
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -64,15 +62,19 @@
6462
)
6563
@click.option(
6664
'-l',
67-
# type = click.File(mode = 'a'),
6865
type = click.Path(file_okay = True, dir_okay = False, resolve_path = True),
6966
help = ('Use the "log-file" to write logs to.')
7067
)
68+
@click.option(
69+
'-j', '--json',
70+
is_flag = True,
71+
help = 'Format output as JSON instead of traditional loggedfs format.'
72+
)
7173
@click.argument(
7274
'directory',
7375
type = click.Path(exists = True, file_okay = False, dir_okay = True, resolve_path = True)
7476
)
75-
def cli_entry(f, p, c, s, l, directory):
77+
def cli_entry(f, p, c, s, l, json, directory):
7678
"""LoggedFS-python is a transparent fuse-filesystem which allows to log
7779
every operations that happens in the backend filesystem. Logs can be written
7880
to syslog, to a file, or to the standard output. LoggedFS comes with an XML
@@ -84,7 +86,7 @@ def cli_entry(f, p, c, s, l, directory):
8486

8587
loggedfs_factory(
8688
directory,
87-
**__process_config__(c, l, s, f, p)
89+
**__process_config__(c, l, s, f, p, json)
8890
)
8991

9092

@@ -93,48 +95,29 @@ def __process_config__(
9395
log_file,
9496
log_syslog_off,
9597
fuse_foreground_bool,
96-
fuse_allowother_bool
98+
fuse_allowother_bool,
99+
log_json
97100
):
98101

99-
def proc_filter_item(in_item):
100-
return {
101-
'extension': in_item['@extension'],
102-
'uid': in_item['@uid'],
103-
'action': in_item['@action'],
104-
'retname': in_item['@retname']
105-
}
106-
107-
def proc_filter_list(in_list):
108-
if in_list is None:
109-
return []
110-
if not isinstance(in_list, list):
111-
return [proc_filter_item(in_list)]
112-
return [proc_filter_item(item) for item in in_list]
113-
114-
config_dict = OrderedDict({
115-
'@logEnabled': True,
116-
'@printProcessName': True,
117-
'includes': {},
118-
'excludes': {}
119-
})
120-
121-
config_file = None
122102
if config_fh is not None:
123-
config_file = config_fh.name
124-
config_dict.update(xmltodict.parse(config_fh.read())['loggedFS'])
103+
config_xml_str = config_fh.read()
125104
config_fh.close()
105+
config_file = config_fh.name
106+
else:
107+
config_file = '[None]'
108+
config_xml_str = None
126109

127-
for f_type in ['includes', 'excludes']:
128-
config_dict[f_type] = proc_filter_list(config_dict[f_type].get(f_type[:-1], None))
110+
config_dict = parse_filters(config_xml_str)
129111

130112
return {
131-
'log_includes': config_dict['includes'],
132-
'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'],
133117
'log_file': log_file,
134118
'log_syslog': not log_syslog_off,
135119
'log_configmsg': 'LoggedFS-python using configuration file %s' % config_file,
136-
'log_enabled': config_dict['@logEnabled'],
137-
'log_printprocessname': config_dict['@printProcessName'],
120+
'log_json': log_json,
138121
'fuse_foreground_bool': fuse_foreground_bool,
139122
'fuse_allowother_bool': fuse_allowother_bool
140123
}

0 commit comments

Comments
 (0)