const char *str = argv[1];
if (!strcmp(str, "default")) {
- gd->log_fmt = LOGF_DEFAULT;
+ gd->log_fmt = log_get_default_format();
} else if (!strcmp(str, "all")) {
gd->log_fmt = LOGF_ALL;
} else {
"log format <fmt> - set log output format. <fmt> is a string where\n"
"\teach letter indicates something that should be displayed:\n"
"\tc=category, l=level, F=file, L=line number, f=function, m=msg\n"
- "\tor 'default', equivalent to 'fm', or 'all' for all\n"
+ "\tor 'default', or 'all' for all\n"
"log rec <category> <level> <file> <line> <func> <message> - "
"output a log record"
;
log message is shown - other details like level, category, file and
line number are omitted.
+config LOGF_FILE
+ bool "Show source file name in log messages by default"
+ help
+ Show the source file name in log messages by default. This value
+ can be overridden using the 'log format' command.
+
+config LOGF_LINE
+ bool "Show source line number in log messages by default"
+ help
+ Show the source line number in log messages by default. This value
+ can be overridden using the 'log format' command.
+
+config LOGF_FUNC
+ bool "Show function name in log messages by default"
+ help
+ Show the function name in log messages by default. This value can
+ be overridden using the 'log format' command.
+
config LOG_SYSLOG
bool "Log output to syslog server"
depends on NET
#include <stdio.h>
#include <linker_lists.h>
#include <dm/uclass-id.h>
+#include <linux/bitops.h>
#include <linux/list.h>
struct cmd_tbl;
LOGF_MSG,
LOGF_COUNT,
- LOGF_DEFAULT = (1 << LOGF_FUNC) | (1 << LOGF_MSG),
LOGF_ALL = 0x3f,
};
}
#endif
+/**
+ * log_get_default_format() - get default log format
+ *
+ * The default log format is configurable via
+ * CONFIG_LOGF_FILE, CONFIG_LOGF_LINE, CONFIG_LOGF_FUNC.
+ *
+ * Return: default log format
+ */
+static inline int log_get_default_format(void)
+{
+ return BIT(LOGF_MSG) |
+ (IS_ENABLED(CONFIG_LOGF_FILE) ? BIT(LOGF_FILE) : 0) |
+ (IS_ENABLED(CONFIG_LOGF_LINE) ? BIT(LOGF_LINE) : 0) |
+ (IS_ENABLED(CONFIG_LOGF_FUNC) ? BIT(LOGF_FUNC) : 0);
+}
+
#endif
DECLARE_GLOBAL_DATA_PTR;
+#define LOGF_TEST (BIT(LOGF_FUNC) | BIT(LOGF_MSG))
+
/**
* struct sb_log_env - private data for sandbox ethernet driver
*
int old_log_level = gd->default_log_level;
struct sb_log_env env;
- gd->log_fmt = LOGF_DEFAULT;
+ gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
env_set("log_hostname", "sandbox");
/* Check that the callback function was called */
sandbox_eth_set_tx_handler(0, NULL);
gd->default_log_level = old_log_level;
+ gd->log_fmt = log_get_default_format();
return 0;
}
int old_log_level = gd->default_log_level;
struct sb_log_env env;
- gd->log_fmt = LOGF_DEFAULT;
+ gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
env_set("log_hostname", "sandbox");
/* Check that the callback function was called */
ut_assertnull(env.expected);
gd->default_log_level = old_log_level;
+ gd->log_fmt = log_get_default_format();
return 0;
}
int old_log_level = gd->default_log_level;
struct sb_log_env env;
- gd->log_fmt = LOGF_DEFAULT;
+ gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
env_set("log_hostname", "sandbox");
/* Check that the callback function was called */
ut_assertnull(env.expected);
gd->default_log_level = old_log_level;
+ gd->log_fmt = log_get_default_format();
return 0;
}
int old_log_level = gd->default_log_level;
struct sb_log_env env;
- gd->log_fmt = LOGF_DEFAULT;
+ gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
env_set("log_hostname", "sandbox");
/* Check that the callback function was called */
ut_assertnull(env.expected);
gd->default_log_level = old_log_level;
+ gd->log_fmt = log_get_default_format();
return 0;
}
int old_log_level = gd->default_log_level;
struct sb_log_env env;
- gd->log_fmt = LOGF_DEFAULT;
+ gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_DEBUG;
env_set("ethact", "eth@10002000");
env_set("log_hostname", "sandbox");
/* Check that the callback function was called */
ut_assertnull(env.expected);
gd->default_log_level = old_log_level;
+ gd->log_fmt = log_get_default_format();
return 0;
}
int old_log_level = gd->default_log_level;
struct sb_log_env env;
- gd->log_fmt = LOGF_DEFAULT;
+ gd->log_fmt = LOGF_TEST;
gd->default_log_level = LOGL_INFO;
env_set("ethact", "eth@10002000");
env_set("log_hostname", "sandbox");
/* Check that the callback function was not called */
ut_assertnonnull(env.expected);
gd->default_log_level = old_log_level;
+ gd->log_fmt = log_get_default_format();
return 0;
}