Unitech / Unitech/pm2

Python logging package always logs to pm2 error

Open
#4,817 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

When managing a python3 script with pm2, if you use the logging package it always outputs as an error log to pm2 even if the level is set to "WARNING" or "DEBUG" or "INFO"

How could we reproduce this issue?

rune this python script with pm2 and look at the log output


import logging

logging.basicConfig(level=logging.DEBUG)

logging.info("this is not an error")
logging.error("this is an error")

Supporting information

                                                                                                                                                                                                                                                                                                                                                                       ```                                                                                                                                                                                                                                                                                                                                                                        --- PM2 report ----------------------------------------------------------------                                                                                                                                                                                                                                                                                            Date                 : Mon Aug 17 2020 23:37:34 GMT+0000 (Coordinated Universal Time)                                                                                                                                                                                                                                                                                      ===============================================================================                                                                                                                                                                                                                                                                                            --- Daemon -------------------------------------------------                                                                                                                                                                                                                                                                                                               pm2d version         : 4.4.0                                                                                                                                                                                                                                                                                                                                               node version         : 10.19.0                                                                                                                                                                                                                                                                                                                                             node path            : /usr/local/bin/pm2                                                                                                                                                                                                                                                                                                                                  argv                 : /usr/bin/node,/usr/local/lib/node_modules/pm2/lib/Daemon.js                                                                                                                                                                                                                                                                                         argv0                : node                                                                                                                                                                                                                                                                                                                                                user                 : iq                                                                                                                                                                                                                                                                                                                                                  uid                  : 1000                                                                                                                                                                                                                                                                                                                                                gid                  : 1000                                                                                                                                                                                                                                                                                                                                                uptime               : 23min                                                                                                                                                                                                                                                                                                                                               ===============================================================================                                                                                                                                                                                                                                                                                            --- CLI ----------------------------------------------------                                                                                                                                                                                                                                                                                                               local pm2            : 4.4.0                                                                                                                                                                                                                                                                                                                                               node version         : 10.19.0                                                                                                                                                                                                                                                                                                                                             node path            : /usr/local/bin/pm2                                                                                                                                                                                                                                                                                                                                  argv                 : /usr/bin/node,/usr/local/bin/pm2,report                                                                                                                                                                                                                                                                                                             argv0                : node                                                                                                                                                                                                                                                                                                                                                user                 : iq                                                                                                                                                                                                                                                                                                                                                  uid                  : 1000                                                                                                                                                                                                                                                                                                                                                gid                  : 1000                                                                                                                                                                                                                                                                                                                                                ===============================================================================                                                                                                                                                                                                                                                                                            --- System info --------------------------------------------                                                                                                                                                                                                                                                                                                               arch                 : x64                                                                                                                                                                                                                                                                                                                                                 platform             : linux                                                                                                                                                                                                                                                                                                                                               type                 : Linux                                                                                                                                                                                                                                                                                                                                               cpus                 : Intel(R) Xeon(R) CPU E5-2650L v3 @ 1.80GHz                                                                                                                                                                                                                                                                                                          cpus nb              : 1                                                                                                                                                                                                                                                                                                                                                   freemem              : 70295552                                                                                                                                                                                                                                                                                                                                            totalmem             : 1029009408                                                                                                                                                                                                                                                                                                                                          home                 : /home/iq                                                                                                                                                                                                                                                                                                                                            ===============================================================================                                                                                                                                                                                                                                                                                            --- PM2 list -----------------------------------------------                                                                                                                                                                                                                                                                                                               ┌─────┬──────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐                                                                                                                                                                                                                                    │ id  │ name     │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │                                                                                                                                                                                                                                    ├─────┼──────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤                                                                                                                                                                                                                                    │ 0   │ ROGUE    │ default     │ N/A     │ fork    │ 20637    │ 23m    │ 0    │ online    │ 0%       │ 53.1mb   │ iq       │ disabled │                                                                                                                                                                                                                                    └─────┴──────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘                                                                                                                                                                                                                                    ===============================================================================                                                                                                                                                                                                                                                                                            --- Daemon logs --------------------------------------------                                                                                                                                                                                                                                                                                                               /home/iq/.pm2/pm2.log last 20 lines:                                                                                                                                                                                                                                                                                                                                       PM2        | 2020-08-14T15:52:41: PM2 log: pm2 has been killed by signal, dumping process list before exit...                                                                                                                                                                                                                                                              PM2        | 2020-08-14T15:52:41: PM2 log: Exited peacefully                                                                                                                                                                                                                                                                                                               PM2        | 2020-08-17T23:13:35: PM2 log: ===============================================================================                                                                                                                                                                                                                                                 PM2        | 2020-08-17T23:13:35: PM2 log: --- New PM2 Daemon started ----------------------------------------------------                                                                                                                                                                                                                                                 PM2        | 2020-08-17T23:13:35: PM2 log: Time                 : Mon Aug 17 2020 23:13:35 GMT+0000 (Coordinated Universal Time)                                                                                                                                                                                                                                           PM2        | 2020-08-17T23:13:35: PM2 log: PM2 version          : 4.4.0                                                                                                                                                                                                                                                                                                    PM2        | 2020-08-17T23:13:35: PM2 log: Node.js version      : 10.19.0                                                                                                                                                                                                                                                                                                  PM2        | 2020-08-17T23:13:35: PM2 log: Current arch         : x64                                                                                                                                                                                                                                                                                                      PM2        | 2020-08-17T23:13:35: PM2 log: PM2 home             : /home/iq/.pm2                                                                                                                                                                                                                                                                                            PM2        | 2020-08-17T23:13:35: PM2 log: PM2 PID file         : /home/iq/.pm2/pm2.pid                                                                                                                                                                                                                                                                                    PM2        | 2020-08-17T23:13:35: PM2 log: RPC socket file      : /home/iq/.pm2/rpc.sock                                                                                                                                                                                                                                                                                   PM2        | 2020-08-17T23:13:35: PM2 log: BUS socket file      : /home/iq/.pm2/pub.sock                                                                                                                                                                                                                                                                                   PM2        | 2020-08-17T23:13:35: PM2 log: Application log path : /home/iq/.pm2/logs                                                                                                                                                                                                                                                                                       PM2        | 2020-08-17T23:13:35: PM2 log: Worker Interval      : 30000                                                                                                                                                                                                                                                                                                    PM2        | 2020-08-17T23:13:35: PM2 log: Process dump file    : /home/iq/.pm2/dump.pm2                                                                                                                                                                                                                                                                                   PM2        | 2020-08-17T23:13:35: PM2 log: Concurrent actions   : 2                                                                                                                                                                                                                                                                                                        PM2        | 2020-08-17T23:13:35: PM2 log: SIGTERM timeout      : 1600                                                                                                                                                                                                                                                                                                     PM2        | 2020-08-17T23:13:35: PM2 log: ===============================================================================                                                                                                                                                                                                                                                 PM2        | 2020-08-17T23:13:42: PM2 log: App [ROGUE:0] starting in -fork mode-                                                                                                                                                                                                                                                                                           PM2        | 2020-08-17T23:13:42: PM2 log: App [ROGUE:0] online                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues     

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Python script under PM2 4.4.0 and compare its INFO, DEBUG, WARNING, and ERROR output. Trace PM2's handling of the managed process's stdout and stderr to find where the stream is classified. Done means non-error Python log levels appear in the appropriate PM2 output without changing the error level.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, python
Domain
cli, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.