From 4bff5dc73b5feda1470bca89cac8400a0366cf24 Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Mon, 9 May 2016 14:10:31 +0800 Subject: [PATCH 1/2] Add verbose option Add verbose option for printing more info about the progress on user's console. In verbose mode, gnsync will print the logs used to be only in log file on the standard output console as well. --- geeknote/gnsync.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/geeknote/gnsync.py b/geeknote/gnsync.py index 9b5342d..d6682a0 100644 --- a/geeknote/gnsync.py +++ b/geeknote/gnsync.py @@ -7,6 +7,7 @@ import logging import string import unicodedata, re +import sys from geeknote import GeekNote from storage import Storage @@ -316,6 +317,7 @@ def main(): parser.add_argument('--notebook', '-n', action='store', help='Notebook name for synchronize. Default is default notebook') parser.add_argument('--logpath', '-l', action='store', help='Path to log file. Default is GeekNoteSync in home dir') parser.add_argument('--two-way', '-t', action='store', help='Two-way sync') + parser.add_argument('--verbose', '-v', action='store_true', help='Verbose mode. Let GNSync print more logs about its progress') args = parser.parse_args() @@ -328,6 +330,12 @@ def main(): reset_logpath(logpath) + if args.verbose: + handler = logging.StreamHandler(sys.stdout) + formatter = logging.Formatter('%(message)s') + handler.setFormatter(formatter) + logger.addHandler(handler) + GNS = GNSync(notebook, path, mask, format, twoway) GNS.sync() From ebabbc4fdcd3e2b041e7722ea8aae0bcc5496735 Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Mon, 9 May 2016 14:32:11 +0800 Subject: [PATCH 2/2] Add logs for file creation and updating --- geeknote/gnsync.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/geeknote/gnsync.py b/geeknote/gnsync.py index d6682a0..2a90750 100644 --- a/geeknote/gnsync.py +++ b/geeknote/gnsync.py @@ -194,6 +194,7 @@ def _update_file(self, file_note, note): GeekNote().loadNoteContent(note) content = Editor.ENMLtoText(note.content) open(file_note['path'], "w").write(content) + logger.info('File "{0}" was updated'.format(os.path.basename(file_note['path']))) @log def _create_note(self, file_note): @@ -229,6 +230,7 @@ def _create_file(self, note): content = Editor.ENMLtoText(note.content) path = os.path.join(self.path, note.title + self.extension) open(path, "w").write(content) + logger.info('File "{0}" was created'.format(os.path.basename(path))) return True @log