On Thu, Apr 16, 2020 at 8:16 PM Dean Schulze <dean.w.schu...@gmail.com> wrote:
>
> I have a C program with a syslog command like this:
>
> syslog(LOG_INFO, "slurmctrld: initializing resources");
>
> It outputs the first line below in the syslog.  This C code executes a golang 
> binary that also does syslog commands:
>
>     Syslogger, err = syslog.New(syslog.LOG_INFO, "slurmctld")
>     ....
>     Syslogger.Info("slurmctld: initializing resources - completed")
>
> The golang code writes the last 3 entries in the syslog, but they include a 
> PID or thread id:
>
> Apr 16 19:18:37 slurmctld slurmctld: slurmctrld: initializing resources
> Apr 16 19:19:12 slurmctld slurmctld[24785]: slurmctrld: creating resource 
> group
> Apr 16 19:19:15 slurmctld slurmctld[24785]: slurmctrld: creating machines
> Apr 16 19:20:28 slurmctld slurmctld[24785]: slurmctld: initializing resources 
> - completed
>
> In golang is there a way to get syslog messages without the PID so they look 
> the same as from C code?

No, there isn't.  The Go log/syslog package in effect acts like the C
function syslog if LOG_PID is passed to openlog.

If this is important to you I recommend that you just copy the
log/syslog package and edit it for your needs.  It's about 400 lines.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVze3ix%2BUdHU%3Da-zgAxrJo6XXk_qXVekc2QK%3D5gMs2C7A%40mail.gmail.com.

Reply via email to