Skip to content

Conversation

@vanodevium
Copy link
Contributor

This small code allows to use /dev/null as logFile

Worker::$logFile = '/dev/null';

static::$logFile ??= sprintf('%s/workerman.log', dirname(__DIR__, 2));

if (!is_file(static::$logFile)) {
if (!is_file(static::$logFile) && static::$logFile !== '/dev/null') {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@joanhey joanhey Dec 15, 2023

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, ...)
  • ...

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

@walkor walkor merged commit 0c0ac0d into walkor:master Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants