Unable to log to stdout for pgadmin4 in python3

Поиск
Список
Период
Сортировка
Искать

Unable to log to stdout for pgadmin4 in python3

От:
Glen Huang <heyhgl@gmail.com>
Дата:
Hi,

I’m running pgadmin4 in docker, and I have set LOG_FILE = '/dev/stdout’ to log to stdout, but when running pgAdmin4.py, it fails with:

Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py", line 56, in    app = create_app() File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 183, in create_app   fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8') File "/usr/local/lib/python3.6/logging/__init__.py", line 1030, in __init__   StreamHandler.__init__(self, self._open()) File "/usr/local/lib/python3.6/logging/__init__.py", line 1059, in _open   return open(self.baseFilename, self.mode, encoding=self.encoding)
OSError: [Errno 29] Invalid seek

I think it has something do with this:

https://bugs.python.org/issue27805

Is there any way to work around it so I can make pgadmin4 log to stdout?

Regards
Glen

Re: Unable to log to stdout for pgadmin4 in python3

От:
Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com>
Дата:
I don't think that's possible with FileHandler in python.

The workaround is to change the logging FileHandler to StreamHandler, If you have access to pgAdmin4 source code in docker then you can try replacing below line (File:  <YOUR_DOCKER_PATH>/pgadmin4/web/pgadmin/__init__.py),

fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8')

with

fh = logging.StreamHandler(sys.stdout)

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



On Wed, Sep 6, 2017 at 8:30 PM, Glen Huang <heyhgl@gmail.com> wrote:
Hi,

I’m running pgadmin4 in docker, and I have set LOG_FILE = '/dev/stdout’ to log to stdout, but when running pgAdmin4.py, it fails with:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py", line 56, in <module>
    app = create_app()
  File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 183, in create_app
    fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8')
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1030, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1059, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
OSError: [Errno 29] Invalid seek

I think it has something do with this:

https://bugs.python.org/issue27805

Is there any way to work around it so I can make pgadmin4 log to stdout?

Regards
Glen

Re: Unable to log to stdout for pgadmin4 in python3

От:
Glen Huang <heyhgl@gmail.com>
Дата:
Thanks for offering the solution. I’ll try to apply it for now.

But ideally it could be fixed in pgadmin, since LOG_FILE is now ignored all together.

Should I submit a ticket to pgadmin's issue tracker? (does it have one?)

On 7 Sep 2017, at 12:34 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> wrote:

I don't think that's possible with FileHandler in python.

The workaround is to change the logging FileHandler to StreamHandler, If you have access to pgAdmin4 source code in docker then you can try replacing below line (File:  <YOUR_DOCKER_PATH>/pgadmin4/web/pgadmin/__init__.py),

fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8')

with

fh = logging.StreamHandler(sys.stdout)

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



On Wed, Sep 6, 2017 at 8:30 PM, Glen Huang <heyhgl@gmail.com> wrote:
Hi,

I’m running pgadmin4 in docker, and I have set LOG_FILE = '/dev/stdout’ to log to stdout, but when running pgAdmin4.py, it fails with:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py", line 56, in <module>
    app = create_app()
  File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 183, in create_app
    fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8')
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1030, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1059, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
OSError: [Errno 29] Invalid seek

I think it has something do with this:

https://bugs.python.org/issue27805

Is there any way to work around it so I can make pgadmin4 log to stdout?

Regards
Glen


Re: Unable to log to stdout for pgadmin4 in python3

От:
Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com>
Дата:
This is not a bug with pgAdmin4 but anyways you can submit feature request to provide option to log only on stdout instead of file.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



On Thu, Sep 7, 2017 at 10:12 AM, Glen Huang <heyhgl@gmail.com> wrote:
Thanks for offering the solution. I’ll try to apply it for now.

But ideally it could be fixed in pgadmin, since LOG_FILE is now ignored all together.

Should I submit a ticket to pgadmin's issue tracker? (does it have one?)

On 7 Sep 2017, at 12:34 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> wrote:

I don't think that's possible with FileHandler in python.

The workaround is to change the logging FileHandler to StreamHandler, If you have access to pgAdmin4 source code in docker then you can try replacing below line (File:  <YOUR_DOCKER_PATH>/pgadmin4/web/pgadmin/__init__.py),

fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8')

with

fh = logging.StreamHandler(sys.stdout)

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



On Wed, Sep 6, 2017 at 8:30 PM, Glen Huang <heyhgl@gmail.com> wrote:
Hi,

I’m running pgadmin4 in docker, and I have set LOG_FILE = '/dev/stdout’ to log to stdout, but when running pgAdmin4.py, it fails with:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py", line 56, in <module>
    app = create_app()
  File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 183, in create_app
    fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8')
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1030, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1059, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
OSError: [Errno 29] Invalid seek

I think it has something do with this:

https://bugs.python.org/issue27805

Is there any way to work around it so I can make pgadmin4 log to stdout?

Regards
Glen



Re: Unable to log to stdout for pgadmin4 in python3

От:
Glen Huang <heyhgl@gmail.com>
Дата:
That sounds reasonable.

Thanks.

On 7 Sep 2017, at 12:50 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> wrote:

This is not a bug with pgAdmin4 but anyways you can submit feature request to provide option to log only on stdout instead of file.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



On Thu, Sep 7, 2017 at 10:12 AM, Glen Huang <heyhgl@gmail.com> wrote:
Thanks for offering the solution. I’ll try to apply it for now.

But ideally it could be fixed in pgadmin, since LOG_FILE is now ignored all together.

Should I submit a ticket to pgadmin's issue tracker? (does it have one?)

On 7 Sep 2017, at 12:34 PM, Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> wrote:

I don't think that's possible with FileHandler in python.

The workaround is to change the logging FileHandler to StreamHandler, If you have access to pgAdmin4 source code in docker then you can try replacing below line (File:  <YOUR_DOCKER_PATH>/pgadmin4/web/pgadmin/__init__.py),

fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8')

with

fh = logging.StreamHandler(sys.stdout)

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



On Wed, Sep 6, 2017 at 8:30 PM, Glen Huang <heyhgl@gmail.com> wrote:
Hi,

I’m running pgadmin4 in docker, and I have set LOG_FILE = '/dev/stdout’ to log to stdout, but when running pgAdmin4.py, it fails with:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py", line 56, in <module>
    app = create_app()
  File "/usr/local/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 183, in create_app
    fh = logging.FileHandler(config.LOG_FILE, encoding='utf-8')
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1030, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.6/logging/__init__.py", line 1059, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
OSError: [Errno 29] Invalid seek

I think it has something do with this:

https://bugs.python.org/issue27805

Is there any way to work around it so I can make pgadmin4 log to stdout?

Regards
Glen




FAQ