From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 395157F00 for ; Wed, 5 Oct 2016 14:18:45 +0200 (CEST) Received: from lfbn-1-5996-232.w90-110.abo.wanadoo.fr ([90.110.195.232] helo=[192.168.1.13]) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1brlCr-0001QC-Q9; Wed, 05 Oct 2016 14:21:54 +0200 To: "Montorsi, Francesco" , "dev@dpdk.org" References: <32054c5dd466431ebf99d84641c6313a@bilemail1.empirix.com> <4b3ed268f2584b4aaf251ba39f8c90bf@bilemail1.empirix.com> From: Olivier Matz Message-ID: Date: Wed, 5 Oct 2016 14:18:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: <4b3ed268f2584b4aaf251ba39f8c90bf@bilemail1.empirix.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] Proposal: enable redirection of DPDK logs from the user app X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2016 12:18:45 -0000 Hi Francesco, On 10/04/2016 02:28 PM, Montorsi, Francesco wrote: > Hi Olivier, > >> It seems the mailing list stripped your patch sent as attachment. >> Can you please resend it again in the body of the mail? > You're right sorry. It's attached at the end of this mail. > >> I think we can already redirect logs to a file by using >> fopencookie() + rte_openlog_stream(). Did you already check these >> functions? > > Yes, but to be honest, that seems a troublesome solution for > something as easy as logging a string; e.g. by using fopencookie() > approach, you don't have the concept of "log message", you just > provide a function that must write a block of bytes somewhere. > Typically instead, you need to know where a log message starts and > ends, to e.g., add prefixes/postfixes to it. I'm not sure that true if you call setbuf(log_stream, NULL). In that case, it looks easy to prefix / postfix messages with a fopencookie callback like: /* example on stdout */ ssize_t simple_write(void *c, const char *buf, size_t size) { ssize_t ret1, ret2, ret3; ret1 = fwrite("<", 1, 1, stdout); if (ret1 == 0) return 0; ret2 = fwrite(buf, size, 1, stdout); if (ret2 == 0) return 0; ret3 = fwrite(">", 1, 1, stdout); if (ret3 == 0) return 0; return ret1 + ret2 + ret3; } > Indeed, most of the C/C++ (open source) libraries have some simple > hook that allows the user to have more control on logging... I think > DPDK should be no exception... :) I understand that the current API is a bit more complex, but I don't feel there is any blocking issue to do what you want. What do you think? Also, I know you've said your patch needs some rework, but as you've also said you are using it, maybe it would be useful for you to know: - it makes use of a global variable 'log_buffer', shared by all the pthreads, which can lead to crashes - it strips the log messages to 4095 chars Regards, Olivier