Skip to content

CODE_FILE/CODE_LINE/CODE_FUNC #2

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

Open
glensc opened this issue Mar 6, 2014 · 7 comments
Open

CODE_FILE/CODE_LINE/CODE_FUNC #2

glensc opened this issue Mar 6, 2014 · 7 comments

Comments

@glensc
Copy link

glensc commented Mar 6, 2014

could those values be adjusted to be addresses of php sourcecode, not C where it was compiled from?

[pid  2520] sendmsg(16, {msg_name(29)={sa_family=AF_LOCAL, sun_path="/run/systemd/journal/socket"}, msg_iov(11)=[{"MESSAGE=hello world", 19}, {"\n", 1}, {"CODE_FILE=/home/users/glen/relup/BUILD.x86_64-linux/php-systemd-0.1/systemd.c", 77}, {"\n", 1}, {"CODE_LINE=58", 12}, {"\n", 1}, {"CODE_FUNC=zif_sd_journal_send", 29}, {"\n", 1}, {"SYSLOG_IDENTIFIER=", 18}, {"php", 3}, {"\n", 1}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 163
@davidstrauss
Copy link
Member

I'm not actually sure how to fix that for PHP.

@glensc
Copy link
Author

glensc commented Mar 6, 2014

could i provide same named attributes myself, or systemd c-library always overrides those? i mean perhaps it fills them if the code itself does not send?

@glensc
Copy link
Author

glensc commented Mar 6, 2014

at least it was worth to try. current answer is no:

$ echo "<?php echo sd_journal_send('MESSAGE=hello world', 'CODE_FILE=php.test.php', 'CODE_FUNC=phpfunc', 'CODE_LINE=1');" | strace -ff -esendmsg -s2000 php 
Process 14069 attached
Process 14070 attached
[pid 14070] +++ exited with 0 +++
[pid 14068] sendmsg(16, {msg_name(29)={sa_family=AF_LOCAL, sun_path="/run/systemd/journal/socket"}, msg_iov(17)=[{"MESSAGE=hello world", 19}, {"\n", 1}, {"CODE_FILE=php.test.php", 22}, {"\n", 1}, {"CODE_FUNC=phpfunc", 17}, {"\n", 1}, {"CODE_LINE=1", 11}, {"\n", 1}, {"CODE_FILE=/home/users/glen/relup/BUILD.x86_64-linux/php-systemd-0.1/systemd.c", 77}, {"\n", 1}, {"CODE_LINE=58", 12}, {"\n", 1}, {"CODE_FUNC=zif_sd_journal_send", 29}, {"\n", 1}, {"SYSLOG_IDENTIFIER=", 18}, {"php", 3}, {"\n", 1}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 216
1[pid 14069] +++ exited with 0 +++
+++ exited with 0 +++

but i think it should be something in similar manner. as not all journal messages contain CODE_FILE so it must be something that can be changed.

@glensc
Copy link
Author

glensc commented Mar 6, 2014

it seems to be configured at build time with SD_JOURNAL_SUPPRESS_LOCATION define:
https://github.com/systemd/systemd/blob/v209/src/systemd/sd-journal.h#L53-60

so, perhaps just undefine them always to get access to original symbols? and do the php source code location extraction php way.

btw, i looked python binding, and it also fills the CODE_{FILE,LINE,FUNCTION} from python stracktrace if user hasn't specified them yet:

https://github.com/systemd/python-systemd/blob/master/systemd/journal.py#L46-54

@glensc
Copy link
Author

glensc commented Mar 6, 2014

oh wait, better define SD_JOURNAL_SUPPRESS_LOCATION instead of undefining functions, then it's likely future safe as well :)

@davidstrauss
Copy link
Member

So, I know it's possible to inject a language-specific file and line. We already do this in python-systemd.

@glensc
Copy link
Author

glensc commented Mar 6, 2014

great!

Thaodan added a commit to Thaodan/php-systemd that referenced this issue Mar 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants