Re: [go-nuts] How can I syslog without PID

2020-04-16 Thread Ian Lance Taylor
On Thu, Apr 16, 2020 at 8:16 PM Dean Schulze  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.


Re: [go-nuts] How can I syslog without PID

2020-04-16 Thread Dan Kortschak
You can get the PID with https://golang.org/pkg/os/#Getpid and use that
you construct a string to hand in as tag to syslog.New.

On Thu, 2020-04-16 at 20:16 -0700, Dean Schulze 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?
> 
> -- 
> 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/18e63047-8b38-4276-8584-17d0a5714c21%40googlegroups.com
> .


-- 
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/d7e0ad94a9b527751ee702accc4468284313f643.camel%40kortschak.io.


[go-nuts] How can I syslog without PID

2020-04-16 Thread Dean Schulze
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?

-- 
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/18e63047-8b38-4276-8584-17d0a5714c21%40googlegroups.com.