Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
W wendelin.core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 4
    • Merge requests 4
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • nexedi
  • wendelin.core
  • Merge requests
  • !38

Merged
Created May 30, 2025 by Kirill Smelkov@kirrOwner

fixup! wcfs: py: Log with date and time present

  • Overview 13
  • Commits 2
  • Changes 2

Thomas reports that wcfs crashes in glog.basicConfig on py2 and indeed checking things it looks like this:

wendelin.core/D$ python --version
Python 2.7.18

wendelin.core/D$ wcfs status file://`pwd`/1.fs
Traceback (most recent call last):
  File "/home/kirr/src/wendelin/venv/z-dev/bin/wcfs", line 11, in <module>
    load_entry_point('wendelin.core', 'console_scripts', 'wcfs')()
  File "<decorator-gen-42>", line 2, in main
  File "/home/kirr/src/tools/go/pygolang/golang/__init__.py", line 166, in _goframe
    return f(*argv, **kw)
  File "/home/kirr/src/wendelin/wendelin.core/wcfs/__init__.py", line 1108, in main
    glog.basicConfig(stream=sys.stderr, level=logging.INFO)
  File "/home/kirr/src/wendelin/wendelin.core/wcfs/internal/glog.py", line 36, in basicConfig
    logging.setLogRecordFactory(LogRecord)
AttributeError: 'module' object has no attribute 'setLogRecordFactory'

This happens because while py3 logging has setLogRecordFactory py2 logging does not.

-> Fix that by changing logging.LogRecord on py2 directly.

However fresh review of glog.py module reveals more problems:

On py2 there is no Formatter.formatMessage and so any logging attempt crashes with

Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 868, in emit
    msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 741, in format
    return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 469, in format
    s = self._fmt % record.__dict__
KeyError: 'levelchar'

-> Fix that by moving .levelchar initialization to LogRecord constructor.

Another problem is that glog.basicConfig was ignoring level argument. This way even if the user code from wcfs was invoking it with level=logging.INFO (see f9a40d36 "wcfs: py: Switch loglevel from WARNING -> INFO for wcfs.py commands") no log messages from info level were logged.

-> Fix that by setting root's logger level as instructed.

I'm not sure how I missed all those problem when preparing original patch.

After hereby patch wcfs.py logging is hopefully back to be working properly on both py2 and py3.

/fixes e51bef0d (wcfs: py: Log with date and time present)
/cc @levin.zimmermann
/reported-by @tomo
/reported-on slapos!1815 (comment 236620)

Edited Jun 03, 2025 by Kirill Smelkov
Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: y/glogpy-fix
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7