(core) Update logging in sandbox code, and log tracebacks as single log messages.

Summary:
- Replace logger module by the standard module 'logging'.
- When a log message from the sandbox includes newlines (e.g. for tracebacks),
  keep those lines together in the Node log message.

  Previously each line was a different message, making it difficult to view
  tracebacks, particularly in prod where each line becomes a separate message
  object.

- Fix assorted lint errors.

Test Plan: Added a test for the log-line splitting and escaping logic.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3956
This commit is contained in:
Dmitry S
2023-07-18 11:20:02 -04:00
parent 7fd48364df
commit 534615dd50
46 changed files with 154 additions and 249 deletions

View File

@@ -3,13 +3,13 @@
# and to produce the ActionBundles expected by other code.
import json
import logging
from acl_formula import parse_acl_grist_entities, parse_acl_formula_json
import action_obj
import logger
import textbuilder
log = logger.Logger(__name__, logger.INFO)
log = logging.getLogger(__name__)
class Permissions(object):
@@ -68,7 +68,7 @@ def prepare_acl_table_renames(docmodel, useractions, table_renames_dict):
rule_info["tableId"] = table_renames_dict[rule_info.get("tableId")]
rule_updates.append((rule_rec, {'userAttributes': json.dumps(rule_info)}))
except Exception as e:
log.warn("Error examining aclRule: %s" % (e,))
log.warning("Error examining aclRule: %s", e)
def do_renames():
useractions.doBulkUpdateFromPairs('_grist_ACLResources', resource_updates)
@@ -104,7 +104,7 @@ def prepare_acl_col_renames(docmodel, useractions, col_renames_dict):
rule_info["lookupColId"] = new_col_id
rule_updates.append((rule_rec, {'userAttributes': json.dumps(rule_info)}))
except Exception as e:
log.warn("Error examining aclRule: %s" % (e,))
log.warning("Error examining aclRule: %s", e)
# Go through again checking if anything in ACL formulas is affected by the rename.
for rule_rec in docmodel.aclRules.all: