Commit Graph

36 Commits

Author SHA1 Message Date
Seth Howell
8e65bfc7e4 lib/log: add a check for localtime() failure
localtime() can technically fail and return a NULL
pointer. We should handle this case.

Change-Id: I5f9d11c5f992453ec3e3804bd17f5d05a863d526
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3245
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
2020-07-15 07:09:19 +00:00
Darek Stojaczyk
922d90c806 log: remove backtrace printing
It was broken since long ago. --enable-log-bt doesn't change
anything. log.c expects SPDK_LOG_BACKTRACE_LVL to be defined
for backtrace to work, but it's not defined anywhere.

Apparently nobody needs this, so remove it.

Change-Id: I2313fd24198b0bf718663f2eafee9b5c6efa0a7f
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2194
Community-CI: Broadcom CI
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-06-03 07:39:08 +00:00
Maciej Szwed
a2606d4b5d all: Fix warnings found by gcc 9.3.0 and 9.3.1
Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: Ie7c5b7b1c2d59a1f927eb5602f4ea5a003eff287
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2433
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-06-02 09:51:57 +00:00
Seth Howell
0be5557cad lib: json-nbd remove spdk prefix from static functions.
Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: Idbf8d37fbac4e3a9eff253095efb2525c9094d94
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2364
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-05-21 09:19:00 +00:00
yidong0635
6be2dde969 lib/log: Eliminate waring about format-truncation.
Eliminate this kind of waring by enlarge string size.

Signed-off-by: yidong0635 <dongx.yi@intel.com>
Change-Id: Ib6d4d031fc635ce15e996d606f5164f682ec34b9
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2426
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: GangCao <gang.cao@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-05-19 09:43:44 +00:00
Vitaliy Mysak
cbe9ea52d0 lib/log: add spdk_vlog function
Some users of SPDK API, such as OCF,
may want to generate logs with arguments themselves.
In that case they would need to first create a buffer
and then pass that buffer as a single argument to spdk_log().
This change adds spdk_vlog() which accepts va_list as argument list,
so it is easier to use spdk_log().

Change-Id: Ie2a3ac481035a250fcd68d0f9b8292008ebb6fe0
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1946
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-05-15 08:10:39 +00:00
Vitaliy Mysak
419cd3691e lib/log: add timestamps for spdk_log messages
rocksdb test file changed because
it relied on logs format by doing grep/cut,
so failed after format was changed by this patch.

Change-Id: I81b8747560d7c803faec1650a3ead042bee2508b
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2023
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-05-11 12:34:28 +00:00
Vitaliy Mysak
caa9d4c87a lib/log: allow omiting filename/lineno information
In spdk_log() accept filename = NULL.
If filename is NULL then source information as well
as log level is not displayed.

This change allows to replace all usages of
printf() and fprintf(stderr,) by
SPDK_PRINTF() and SPDK_ERRLOG() which use spdk_log().

Using spdk_log() instead of printf() is always prefered
since SPDK can be used inside of another application
where SPDK logs could be redirected.

SPDK uses printf()
places where location info is not needed
we cannot replace it by SPDK_NOTICELOG().

This change is in the scope earlier planned task:
https://trello.com/c/lZzBjrw3/10-remove-use-of-printf-fprintf-and-perror-for-logging-in-library-code

Change-Id: I55c24da4a2092bd118fa2c121092d253cedb1cf8
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1942
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2020-05-07 10:42:40 +00:00
Richael Zhuang
a2dbaf7e83 log: spdk_log_dump more characters than required
When the size of input buffer is larger than 16 and not divisible
by 16, the final line will keep part of the characters of the last
line. For example, if I want to dump "spdk dump 16 more chars",the
output is:
00000000 "hexadecimal" spdk dump 16 mor
00000010 "hexadecimal" e charsmp 16 mor
But the correct should be:
00000000 "hexadecimal" spdk dump 16 mor
00000010 "hexadecimal" e chars

Signed-off-by: Richael Zhuang <richael.zhuang@arm.com>
Change-Id: Iaf3f33c5ce68920ada83c59277f89a547e8030d7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1739
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2020-04-14 11:34:45 +00:00
Tomasz Zawadzki
16cc6464db lib/log: do not put trailing whitespace in fdump
fdump puts out buffer in following format:
"00000000  76 61 6c 00                                        val.            "

Each buffer is displayed with hex values up to maximum, then
followed up with a value. This is done to keep starting value
with the same alignment between each consecutive line.
Value contents should end at its length instead of
adding trailing whitespace.

After this patch, output is changed to:
"00000000  76 61 6c 00                                        val."

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I26b327e83f296ba3865f1a337f4a70764a80e2b0
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/483706
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2020-02-04 20:08:02 +00:00
fanyang
bb9d17a5c3 lib/log: passing va_list to user-provided log call
va_list is not passed in logfunc, so the user-provided log call can't
get the arguments corresponding to the format string.

This patch fixes it and replaces log func pointer in spdk_app_opts
with logfunc.

Change-Id: I7f7806f47c4fd8f36f3234aa5a8c877db0fc7140
Signed-off-by: Yang Fan <fanyang@smartx.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469828
Reviewed-by: Feng,Li <fengli@smartx.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-10-09 14:35:51 +00:00
x00267701
a50246fb64 log: optimize spdk_log() when logging is disabled
If the log level of the output log is higher than
the process's log level, the system does not output
it, so we needn't generate the formatting logs.

Change-Id: I36be0e6807ed575fcbf1d0ae01f064a6ca2c4539
Signed-off-by: Huiming Xie <xiehuiming@huawei.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462790
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-07-23 00:42:24 +00:00
paul luse
46523f33e0 log: passing user-defined log
Change-Id: I993e15a6e75029b0717960d5da31325e7f3522c1
Signed-off-by: zkhatami88 <z.khatami88@gmail.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456407
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2019-06-18 03:56:50 +00:00
Darek Stojaczyk
1db6c18e60 log/fdump: fix alignment of the last printed line
Our log_ut currently dumps two buffers which end up being
printed with a different column alignment.

`00000000  6c 6f 67 20 64 75 6d 70                           log dump`
vs
`00000000  73 70 64 6b 20 64 75 6d  70                        spdk dump`

In short dumps (len % 16 < 8) we didn't include the extra
arbitrary whitespace between the 8-byte parts.

Change-Id: I00bf1d334f71370922d939c4397a479f8d707112
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452058
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
2019-05-10 10:27:29 +00:00
Jim Harris
b4b7d5d3ff log: remove "trace" from public API
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I90e7d698cae7577736319e38f089e3b759c9beef

Reviewed-on: https://review.gerrithub.io/435343
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
2018-12-03 19:50:15 +00:00
Pawel Wodkowski
ae2b2f64ea log: add a way to turn on and off stack unwinding in logs
As a side effect, if SPDK_LOG_DISABLED is used in spdk_log() as log
level then no message will be printed.

Change-Id: I2d57b60a5a310a9ef2a1187a81088d0acf828742
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/425105
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2018-10-02 22:09:27 +00:00
Pawel Wodkowski
848daf274b log: add backtrace option
Add '--enable-log-bt=lvl' option to show simple backtrace in following
form:

thread.c: 346:spdk_io_device_register: *ERROR*: io_device 0xf2ef80
already registered
*ERROR*: === BACKTRACE START ===
*ERROR*:   1: spdk_io_device_register() at 0x6d64df
*ERROR*:   2:  spdk_copy_engine_initialize() at 0x71059c
*ERROR*:   3:   spdk_copy_engine_subsystem_initialize() at 0x572ed0
*ERROR*:   4:    spdk_subsystem_init_next() at 0x6ca756
*ERROR*:   5:     spdk_subsystem_verify() at 0x6caba7
*ERROR*:   6:      _spdk_event_queue_run_batch() at 0x6c1ffa
*ERROR*:   7:       _spdk_reactor_run() at 0x6c5349
*ERROR*:   8:        spdk_reactors_start() at 0x6c784f
*ERROR*:   9:         spdk_app_start() at 0x6bf18e
*ERROR*: === BACKTRACE END ===

This adds additional libunwind dependency so don't enable by default.

Change-Id: Ice93d7571a000d8a57d2fedda7670c9a0b6ff7b7
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/419726
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2018-07-25 15:48:25 +00:00
Ed Rodriguez
85c146ef6e log: Create a separate implementation file for common log flag operations.
Change-Id: I2524b7881885a0784492a8189bf22a0b8c92d470
Signed-off-by: Ed rodriguez <edwinr@netapp.com>
Reviewed-on: https://review.gerrithub.io/386169
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-11-14 15:53:37 -05:00
Daniel Verkamp
31521306a5 log: change spdk_trace_dump() to take a void *
Previously, spdk_trace_dump() took a const uint8_t * as the buffer, but
it is more flexible to allow any type to be passed (we are just going to
interpret it as an array of bytes anyway).

Change-Id: I1750316928cd330ed461bb513ff8af37e0170ef3
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/382854
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-10-17 16:26:02 -04:00
Paul Luse
9b99f2c0f3 log: add new parm to spdk_trace_dump()
Allows called to specify something other than stderr such as
stdout. Existing callers updated to use stderr.

Change-Id: I48a703e1474a45952878121a83c19fef1c43d630
Signed-off-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/377420
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: John Kariuki <John.K.Kariuki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-09-06 17:33:03 -04:00
Daniel Verkamp
932a186b4c log: remove uses of SPDK_TRACE_DEBUG
Replace SPDK_TRACE_DEBUG with component-specific flags.

Change-Id: Iee7eafab5e6ac8713f247323a18552b5afb0e86a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/375834
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-08-29 15:07:13 -04:00
Ben Walker
ad474e95bb log: Remove configurable log facility
Always use "Local7" internally. We want the log API
to be generic instead of syslog specific.

Change-Id: I021f719e90c236f123fa1cadebc0c199b87ba077
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365295
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-07-05 19:28:29 -04:00
Ben Walker
65918cb8ff log: Add a print to stderr threshold
Change-Id: I9c1865ff1ca2d8093227c89aa9857ff18d3e346a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365294
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-20 13:34:47 -04:00
Ben Walker
cca697b0ec log: Reduce lots of duplicated code
Use the log level enum to eliminate the variants of the log
function.

Change-Id: I5bd0e7b4f84f78dab86a5102baa6baa0808627a8
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365293
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2017-06-20 13:34:47 -04:00
Ben Walker
235a8e377e log: Rename, document the open and close calls
Name them spdk_log_open and spdk_log_close, and give them
API documentation.

Change-Id: I6c2bbdd6a32894c1e030ec70a97dc054cd7102a9
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365292
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-16 16:15:06 -04:00
Ben Walker
dda26fba8b log: Change priority to generic log level
The log priority was very syslog specific. Instead, create
a generic set of log levels as an enum.

The log level/priority isn't actually used anywhere today.

Change-Id: Iebcf6b7e1b263b56f317b86b5f2ea0d9e45170f3
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365267
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
2017-06-16 16:15:06 -04:00
Ed Rodriguez
2d2fde0d7f log: Use SPDK_ERRLOG in lieu of fprintf(stderr
Change-Id: Ic87d62516324b9c388a932b268714255b15a9a57
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-09 11:28:28 -07:00
Ben Walker
b961d9cc12 include: Move the remainder of the code base to stdinc.h
Change-Id: I6a142feeaad3117bd3c75e7c5cb7231a1cfa78ae
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
2017-05-08 13:20:36 -07:00
Tsuyoshi Uchida
5ee4728d0c log: define prioritynames[] (#102) 2017-01-23 16:07:29 -07:00
Tsuyoshi Uchida
950b48de61 log: use facilitynames to set/get log facility (#81)
* log: use facilitynames to set/get log facility

Define our own facilitynames[] instead of defining SYSLOG_NAMES
2017-01-17 11:20:34 -07:00
Daniel Verkamp
c454900960 log: print trace flag names in SPDK_TRACELOG()
Change-Id: I962ee098818f48563e67f9b4214bc3519eee48b4
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-28 13:15:08 -07:00
Daniel Verkamp
d27b24c94b log: split internal TRACELOG macro into new header
The SPDK_TRACELOG macro depends on a CONFIG setting (DEBUG), so it
should not be part of the public API.

Create a new include/spdk_internal directory for headers that should
only be used within SPDK, not exported for public use.

Change-Id: I39b90ce57da3270e735ba32210c4b3a3468c460b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-11-16 13:33:51 -07:00
Krzysztof Jakimiak
25749728b6 spdk: tweak tracedump
Increased printed data width, added data offset indices.

Change-Id: I44f81396e33870109c2bece5e152657f8a24a56a
Signed-off-by: Krzysztof Jakimiak <krzysztof.jakimiak@intel.com>
2016-10-05 09:40:21 -07:00
Daniel Verkamp
20bee521a6 log: dynamically generate usage for -t option
Change-Id: I8c709b507c4cb00092d5dc9b1e8ca1c0fe880b02
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-08-22 16:57:19 -07:00
Daniel Verkamp
8f4ef2a843 log: allow setting all trace flags at once
Add a special "all" trace flag name to set or clear all registered trace
flags.

Change-Id: Ib579df7c41ce4aca72174e04734df20f2752035c
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-12 09:47:57 -07:00
Daniel Verkamp
aaa533adc7 log: add SPDK logging library
Change-Id: I3d4060b619a3976ffff75c05f86214e3fcd18fb5
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
2016-05-09 15:54:49 -07:00