Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
8ea38bc2
Commit
8ea38bc2
authored
8 years ago
by
Beat Küng
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
logger: better status output with configured backend mode
parent
7a60c129
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/logger/logger.cpp
+31
-20
31 additions, 20 deletions
src/modules/logger/logger.cpp
src/modules/logger/logger.h
+5
-1
5 additions, 1 deletion
src/modules/logger/logger.h
with
36 additions
and
21 deletions
src/modules/logger/logger.cpp
+
31
−
20
View file @
8ea38bc2
...
...
@@ -217,21 +217,15 @@ int Logger::start(char *const *argv)
void
Logger
::
status
()
{
bool
has_start
ed_backend
s
=
false
;
PX4_INFO
(
"Running in mode: %s"
,
configur
ed_backend
_mode
())
;
if
(
_writer
.
is_started
(
LogWriter
::
BackendFile
))
{
PX4_INFO
(
"File Logging Running"
);
print_statistics
();
has_started_backends
=
true
;
}
if
(
_writer
.
is_started
(
LogWriter
::
BackendMavlink
))
{
PX4_INFO
(
"Mavlink Logging Running"
);
has_started_backends
=
true
;
}
if
(
!
has_started_backends
)
{
PX4_INFO
(
"Running, but not logging"
);
}
}
...
...
@@ -241,9 +235,10 @@ void Logger::print_statistics()
return
;
}
/* this is only for the file backend */
float
kibibytes
=
_writer
.
get_total_written_file
()
/
1024.0
f
;
float
mebibytes
=
kibibytes
/
1024.0
f
;
float
seconds
=
((
float
)(
hrt_absolute_time
()
-
_start_time
))
/
1000000.0
f
;
float
seconds
=
((
float
)(
hrt_absolute_time
()
-
_start_time
_file
))
/
1000000.0
f
;
PX4_INFO
(
"Log file: %s/%s"
,
_log_dir
,
_log_file_name
);
PX4_INFO
(
"Wrote %4.2f MiB (avg %5.2f KiB/s)"
,
(
double
)
mebibytes
,
(
double
)(
kibibytes
/
seconds
));
...
...
@@ -607,26 +602,41 @@ int Logger::add_topics_from_file(const char *fname)
return
ntopics
;
}
const
char
*
Logger
::
configured_backend_mode
()
const
{
switch
(
_writer
.
backend
())
{
case
LogWriter
::
BackendFile
:
return
"file"
;
case
LogWriter
::
BackendMavlink
:
return
"mavlink"
;
case
LogWriter
::
BackendAll
:
return
"all"
;
default:
return
"several"
;
}
}
void
Logger
::
run
()
{
#ifdef DBGPRINT
struct
mallinfo
alloc_info
=
{};
#endif
/* DBGPRINT */
PX4_INFO
(
"logger started
"
);
PX4_INFO
(
"logger started
(mode=%s)"
,
configured_backend_mode
()
);
int
mkdir_ret
=
mkdir
(
LOG_ROOT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
_writer
.
backend
()
&
LogWriter
::
BackendFile
)
{
int
mkdir_ret
=
mkdir
(
LOG_ROOT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
mkdir_ret
==
0
)
{
PX4_INFO
(
"log root dir created: %s"
,
LOG_ROOT
);
if
(
mkdir_ret
==
0
)
{
PX4_INFO
(
"log root dir created: %s"
,
LOG_ROOT
);
}
else
if
(
errno
!=
EEXIST
)
{
PX4_ERR
(
"failed creating log root dir: %s"
,
LOG_ROOT
);
return
;
}
}
else
if
(
errno
!=
EEXIST
)
{
PX4_ERR
(
"failed creating log root dir: %s"
,
LOG_ROOT
);
return
;
}
if
(
check_free_space
()
==
1
)
{
return
;
if
(
check_free_space
()
==
1
)
{
return
;
}
}
uORB
::
Subscription
<
vehicle_status_s
>
vehicle_status_sub
(
ORB_ID
(
vehicle_status
));
...
...
@@ -1075,7 +1085,7 @@ void Logger::start_log_file()
return
;
}
PX4_INFO
(
"
s
tart file log"
);
PX4_INFO
(
"
S
tart file log"
);
char
file_name
[
LOG_DIR_LEN
]
=
""
;
...
...
@@ -1096,7 +1106,8 @@ void Logger::start_log_file()
write_all_add_logged_msg
();
_writer
.
set_need_reliable_transfer
(
false
);
_writer
.
notify
();
_start_time
=
hrt_absolute_time
();
_start_time_file
=
hrt_absolute_time
();
}
void
Logger
::
stop_log_file
()
...
...
This diff is collapsed.
Click to expand it.
src/modules/logger/logger.h
+
5
−
1
View file @
8ea38bc2
...
...
@@ -160,6 +160,10 @@ private:
void
stop_log_file
();
/** get the configured backend as string */
const
char
*
configured_backend_mode
()
const
;
/**
* write the file header with file magic and timestamp.
*/
...
...
@@ -222,7 +226,7 @@ private:
// statistics
hrt_abstime
_start_time
;
///< Time when logging started (not the logger thread)
hrt_abstime
_start_time
_file
;
///< Time when logging started
, file backend
(not the logger thread)
hrt_abstime
_dropout_start
=
0
;
///< start of current dropout (0 = no dropout)
float
_max_dropout_duration
=
0.
f
;
///< max duration of dropout [s]
size_t
_write_dropouts
=
0
;
///< failed buffer writes due to buffer overflow
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment