marco
Sorry, we encountered an error while displaying this content. If you're a user, please try again later. If you're an administrator, take a look in your Flarum log files for more information.
manchev
Sorry, we encountered an error while displaying this content. If you're a user, please try again later. If you're an administrator, take a look in your Flarum log files for more information.
marco
Sorry, we encountered an error while displaying this content. If you're a user, please try again later. If you're an administrator, take a look in your Flarum log files for more information.
agentzh
Hello!
On Fri, May 29, 2015 at 3:32 PM, Marco Palladino wrote:
> Unfortunately that module doesn't support logging to a third party file on
> disk. I was wondering if I opening the file once, and storing the handler in
> a global variable to be re-used every time, would work?
>
Yes, you could open the file in append mode and use LuaJITFFI to call
the write() or writev() syscalls directly without going through libc's
buffered I/O layer. You could cache and share the file descriptor on
the nginx worker level via the following technique:
https://github.com/openresty/lua-nginx-module#data-sharing-within-an-nginx-worker
Just my 2 cents :)
Best regards,
-agentzh
manchev
Sorry, we encountered an error while displaying this content. If you're a user, please try again later. If you're an administrator, take a look in your Flarum log files for more information.
agentzh
Hello!
On Fri, May 29, 2015 at 3:55 PM, Vladislav Manchev wrote:
> It won't be possible to share a file descriptor between workers, so it's a
> dead end I think.
>
We don't need to share the log file descriptor across workers in the
first place. Even nginx's builtin logger does not do this. Thanks to
modern operating systems' atomic file appending feature ;)
> Also, not sure what's stopping you from logging to a third party file on
> disk with lua-resty-logger-socket. You can just log to a localhost syslog-ng
> instance (although I never tried that).
>
Sure, AFAIK, syslog-ng server can further log into the file system on
our behalf.
Regards,
-agentzh
marco
Sorry, we encountered an error while displaying this content. If you're a user, please try again later. If you're an administrator, take a look in your Flarum log files for more information.
agentzh
Hello!
On Tue, Jun 2, 2015 at 9:15 AM, Marco Palladino wrote:
> I decided to use "fopen", "fprintf" and "fclose":
>
As mentioned previously, these libc functions are not safe at all in
this context because of its own userland buffering. Use the thin libc
wrappers for the syscalls like write() and writev() directly.
Regards,
-agentzh