-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
worker: allow to set logFile as /dev/null #993
Conversation
@@ -662,7 +662,7 @@ protected static function init(): void | |||
// Log file. | |||
static::$logFile ??= sprintf('%s/workerman.log', dirname(__DIR__, 2)); | |||
|
|||
if (!is_file(static::$logFile)) { | |||
if (!is_file(static::$logFile) && static::$logFile !== '/dev/null') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be better to replace is_file with file_exists function. file_exists can handle /dev/null and other special files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luzrain Thanx!
I didn't want to change the semantics of the code, I only allowed /dev/null
if you insist, please make your own fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to support more options, not only /dev/null
like stderr
, syslog
, database, net, ...
I think that we need to work more with the log with error and access later:
- configure log which data to show
- have more than 1 log
- error log only show by severity (warn, info, ...)
- ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we introduce $noLog option as first step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to create a Log Class, to easily add more options or that a user extend the class in the way he need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very difficult task for me in general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that Walkor want Workerman minimalist, and I think like him.
But a minimal Log Class, that any user could change to his needs will be a good feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we can do the same than nodejs.
node my_app.js > my_app_log.log 2> my_app_err.log
Workerman only log in daemon mode, in debug mode use STDOUT
php start.php start > /dev/null 2> my_app_err.log
Theorically it will work.
This small code allows to use /dev/null as logFile