-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d415d9f
commit 8cdaa07
Showing
9 changed files
with
179 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include "mos/platform/platform.h" | ||
#include "mos/syslog/debug.h" | ||
|
||
typedef enum | ||
{ | ||
MOS_LOG_FATAL = 6, | ||
MOS_LOG_EMERG = 5, | ||
MOS_LOG_WARN = 4, | ||
MOS_LOG_EMPH = 3, | ||
MOS_LOG_INFO = 2, | ||
MOS_LOG_INFO2 = 1, | ||
MOS_LOG_UNSET = 0, | ||
} loglevel_t; | ||
|
||
long do_syslog(loglevel_t level, thread_t *thread, const char *file, const char *func, int line, debug_info_entry *feat, const char *fmt, ...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,5 +38,5 @@ void hexdump(const char *data, const size_t len) | |
} | ||
} | ||
|
||
pr_info(); | ||
pr_info(""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "mos/syslog/syslog.h" | ||
|
||
#include "mos/platform/platform.h" | ||
#include "mos/tasks/task_types.h" | ||
#include "proto/syslog.pb.h" | ||
|
||
#include <mos/compiler.h> | ||
#include <mos/mos_global.h> | ||
#include <mos_stdio.h> | ||
#include <pb_encode.h> | ||
|
||
static spinlock_t global_syslog_lock = SPINLOCK_INIT; | ||
|
||
long do_syslog(loglevel_t level, thread_t *thread, const char *file, const char *func, int line, debug_info_entry *feat, const char *fmt, ...) | ||
{ | ||
pb_syslog_message msg = { | ||
.timestamp = platform_get_timestamp(), | ||
.cpu_id = platform_current_cpu_id(), | ||
}; | ||
|
||
msg.info.level = (syslog_level) level; | ||
msg.info.featid = feat ? feat->id : 0; | ||
msg.info.source_location.line = line; | ||
strncpy(msg.info.source_location.filename, file, sizeof(msg.info.source_location.filename)); | ||
strncpy(msg.info.source_location.function, func, sizeof(msg.info.source_location.function)); | ||
|
||
if (thread) | ||
{ | ||
msg.thread.tid = thread->tid; | ||
msg.process.pid = thread->owner->pid; | ||
strncpy(msg.thread.name, thread->name, sizeof(msg.thread.name)); | ||
strncpy(msg.process.name, thread->owner->name, sizeof(msg.process.name)); | ||
} | ||
|
||
va_list args; | ||
va_start(args, fmt); | ||
vsnprintf(msg.message, sizeof(msg.message), fmt, args); | ||
va_end(args); | ||
|
||
spinlock_acquire(&global_syslog_lock); | ||
|
||
lprintk(level, "\r\n"); | ||
|
||
#if MOS_CONFIG(MOS_PRINTK_WITH_TIMESTAMP) | ||
lprintk(MOS_LOG_UNSET, "%-16llu | ", platform_get_timestamp()); | ||
#endif | ||
|
||
#if MOS_CONFIG(MOS_PRINTK_WITH_DATETIME) | ||
lprintk(MOS_LOG_UNSET, "%s | ", (const char *) platform_get_datetime_str()); | ||
#endif | ||
|
||
#if MOS_CONFIG(MOS_PRINTK_WITH_CPU_ID) | ||
lprintk(MOS_LOG_UNSET, "cpu %2d | ", msg.cpu_id); | ||
#endif | ||
|
||
#if MOS_CONFIG(MOS_PRINTK_WITH_FILENAME) | ||
lprintk(MOS_LOG_UNSET, "%-15s | ", msg.info.source_location.filename); | ||
#endif | ||
|
||
#if MOS_CONFIG(MOS_PRINTK_WITH_THREAD_ID) | ||
lprintk(MOS_LOG_UNSET, "%pt\t| ", ((void *) thread)); | ||
#endif | ||
|
||
lprintk(MOS_LOG_UNSET, "%s", msg.message); | ||
|
||
spinlock_release(&global_syslog_lock); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
syntax = "proto3"; | ||
import "nanopb.proto"; | ||
|
||
option (nanopb_fileopt).fallback_type = FT_STATIC; | ||
option (nanopb_fileopt).proto3_singular_msgs = true; | ||
|
||
enum syslog_level | ||
{ | ||
UNSET = 0; | ||
INFO2 = 1; | ||
INFO = 2; | ||
EMPH = 3; | ||
WARN = 4; | ||
EMERG = 5; | ||
FATAL = 6; | ||
} | ||
|
||
message pb_thread | ||
{ | ||
uint32 tid = 1; | ||
string name = 2 [ (nanopb).max_size = 32 ]; | ||
} | ||
|
||
message pb_process | ||
{ | ||
uint32 pid = 1; | ||
string name = 2 [ (nanopb).max_size = 32 ]; | ||
} | ||
|
||
message pb_source_location | ||
{ | ||
string filename = 1 [ (nanopb).max_size = 32 ]; | ||
uint32 line = 2; | ||
string function = 3 [ (nanopb).max_size = 32 ]; | ||
} | ||
|
||
message pb_syslog_source_info | ||
{ | ||
syslog_level level = 1; | ||
uint32 featid = 2; | ||
pb_source_location source_location = 3; | ||
} | ||
|
||
message pb_syslog_message | ||
{ | ||
uint64 timestamp = 1; | ||
pb_syslog_source_info info = 2; | ||
string message = 3 [ (nanopb).max_size = 512 ]; | ||
|
||
pb_thread thread = 4; | ||
pb_process process = 5; | ||
|
||
uint32 cpu_id = 6; | ||
} |