Commit 38c82a2a authored by eckhart's avatar eckhart

DHParser/templates/DSLServer.pyi updated, so it reflects latest changes in...

DHParser/templates/DSLServer.pyi updated, so it reflects latest changes in examples/EBNF/EBNFServer.py
parent 7836ab9e
......@@ -199,6 +199,8 @@ def create_log(log_name: str) -> str:
if not ldir:
ldir = log_dir()
if ldir:
if not os.path.exists(ldir):
os.makedirs(ldir)
with open(os.path.join(ldir, file_name), 'w', encoding='utf-8') as f:
f.write('LOG-FILE: ' + log_name + '\n\n')
return log_name
......@@ -219,7 +221,7 @@ def append_log(log_name: str, *strings, echo: bool = False) -> None:
:param echo: If True, the log message will be echoed on the terminal. This
will also happen if logging is turned off.
"""
ldir, _ = os.path.split(log_name)
ldir, log_name = os.path.split(log_name)
if not ldir:
ldir = log_dir()
if ldir and log_name:
......
......@@ -754,10 +754,19 @@ class Server:
# self.known_methods.add(name)
def start_logging(self, filename: str = "") -> str:
if not filename:
filename = self.server_name + '_' + hex(id(self))[2:] + '.log'
if not log_dir():
filename = os.path.join('.', filename)
"""Starts logging to a file. If `filename` is void or a directory
an auto-generated file name will be used. The file will be written
to the standard log-dir, unless a path is specified in filename."""
def log_name():
"""Returns an auto-generated log-name."""
return self.server_name + '_' + hex(id(self))[2:] + '.log'
if os.path.isdir(filename) or filename.endswith(os.path.sep):
filename = os.path.join(filename, log_name())
else:
if not filename:
filename = log_name()
if not os.path.dirname(filename) and not log_dir():
filename = os.path.join('.', filename)
self.log_file = create_log(filename)
if self.log_file:
self.log('Python Version: %s\nDHParser Version: %s\n\n'
......@@ -766,6 +775,7 @@ class Server:
return 'Unable to write log-file: "%s"' % filename
def stop_logging(self):
"""Stops logging."""
if self.log_file:
self.log('Logging will be stopped now!')
ret = 'Stopped logging to file: "%s"' % self.log_file
......
......@@ -406,17 +406,17 @@ async def start_server_daemon(host, port, requests) -> list:
def parse_logging_args(args):
if args.logging:
echo = repr('ECHO_ON') if args.startserver else repr('ECHO_OFF')
if args.logging or args.logging is None:
echo = repr('ECHO_ON') if isinstance(args.startserver, list) else repr('ECHO_OFF')
if args.logging in ('OFF', 'STOP', 'NO', 'FALSE'):
log_path = repr(None)
echo = repr('ECHO_OFF')
elif args.logging in ('ON', 'START', 'YES', 'TRUE'):
log_path = repr('')
else:
log_path = args.logging
log_path = repr('') if args.logging is None else repr(args.logging)
request = LOGGING_REQUEST.replace('""', ", ".join((log_path, echo)))
debug('Logging to file %s with call %s' % (repr(log_path), request))
debug('Logging to %s with call %s' % (log_path, request))
return log_path, request
else:
return None, ''
......@@ -439,11 +439,14 @@ if __name__ == "__main__":
help='host name or IP-address of the server (default: 127.0.0.1)')
parser.add_argument('-p', '--port', nargs=1, type=int, default=[-1],
help='port number of the server (default:8888)')
parser.add_argument('-l', '--logging', nargs='?', metavar="ON|LOG_DIR|OFF",
parser.add_argument('-l', '--logging', nargs='?', metavar="ON|LOG_DIR|OFF", default='',
help='turns logging on (default) or off or writes log to a '
'specific directory (implies on)')
parser.add_argument('-b', '--debug', action='store_true', help="debug messages")
args = parser.parse_args()
if args.debug:
DEBUG = True
host = args.host[0]
port = int(args.port[0])
......
......@@ -17,9 +17,7 @@
# - replace the regex_heuristics by an always matching parser
#
# Ambiguities can also be avoided by NOT using all the syntactic variants
# made possible by this EBNF-grammar within one and the same EBNF-document.
# made possible by this EBNF-grammar within one and the same EBNF-docum
@ comment = /(?!#x[A-Fa-f0-9])#.*(?:\n|$)|\/\*(?:.|\n)*?\*\/|\(\*(?:.|\n)*?\*\)/
# comments can be either C-Style: /* ... */
......
......@@ -521,17 +521,17 @@ async def start_server_daemon(host, port, requests) -> list:
def parse_logging_args(args):
if args.logging:
echo = repr('ECHO_ON') if args.startserver else repr('ECHO_OFF')
if args.logging or args.logging is None:
echo = repr('ECHO_ON') if isinstance(args.startserver, list) else repr('ECHO_OFF')
if args.logging in ('OFF', 'STOP', 'NO', 'FALSE'):
log_path = repr(None)
echo = repr('ECHO_OFF')
elif args.logging in ('ON', 'START', 'YES', 'TRUE'):
log_path = repr('')
else:
log_path = args.logging
log_path = repr('') if args.logging is None else repr(args.logging)
request = LOGGING_REQUEST.replace('""', ", ".join((log_path, echo)))
debug('Logging to file %s with call %s' % (repr(log_path), request))
debug('Logging to %s with call %s' % (log_path, request))
return log_path, request
else:
return None, ''
......@@ -554,11 +554,14 @@ if __name__ == "__main__":
help='host name or IP-address of the server (default: 127.0.0.1)')
parser.add_argument('-p', '--port', nargs=1, type=int, default=[-1],
help='port number of the server (default:8888)')
parser.add_argument('-l', '--logging', nargs='?', metavar="ON|LOG_DIR|OFF",
parser.add_argument('-l', '--logging', nargs='?', metavar="ON|LOG_DIR|OFF", default='',
help='turns logging on (default) or off or writes log to a '
'specific directory (implies on)')
parser.add_argument('-b', '--debug', action='store_true', help="debug messages")
args = parser.parse_args()
if args.debug:
DEBUG = True
host = args.host[0]
port = int(args.port[0])
......
......@@ -89,7 +89,7 @@ function startLangServerTCP(addr: number) : Disposable {
}
export function activate(context: ExtensionContext) {
// console.log('activating language server connector!');
console.log('activating language server connector!');
let disposable = startLangServerTCP(defaultPort);
context.subscriptions.push(disposable);
}
......
......@@ -206,18 +206,18 @@
}
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dev": true,
"requires": {
"minimist": "0.0.8"
"minimist": "^1.2.5"
}
},
"once": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment