Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
d9189f17
Commit
d9189f17
authored
11 years ago
by
Oleg Hahm
Browse files
Options
Downloads
Patches
Plain Diff
removed unmaintained logd library
parent
31646237
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sys/Makefile
+0
-3
0 additions, 3 deletions
sys/Makefile
sys/logd/Makefile
+0
-6
0 additions, 6 deletions
sys/logd/Makefile
sys/logd/logd.c
+0
-207
0 additions, 207 deletions
sys/logd/logd.c
with
0 additions
and
216 deletions
sys/Makefile
+
0
−
3
View file @
d9189f17
...
...
@@ -10,9 +10,6 @@ endif
ifneq
(,$(findstring lib,$(USEMODULE)))
DIRS
+=
lib
endif
ifneq
(,$(findstring logd,$(USEMODULE)))
DIRS
+=
logd
endif
ifneq
(,$(findstring cmdd,$(USEMODULE)))
DIRS
+=
cmdd
endif
...
...
This diff is collapsed.
Click to expand it.
sys/logd/Makefile
deleted
100644 → 0
+
0
−
6
View file @
31646237
INCLUDES
=
-I
../include
-I
../drivers/include
-I
../lib
-I
$(
RIOTCPU
)
/
$(
CPU
)
/include
-I
../net
-I
../../core/include
MODULE
=
logd
include
$(MAKEBASE)/Makefile.base
This diff is collapsed.
Click to expand it.
sys/logd/logd.c
deleted
100644 → 0
+
0
−
207
View file @
31646237
/**
* Logging daemon
*
* Copyright (C) 2009-2013 Freie Universitaet Berlin
*
* This file subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @file logd.c
* @brief Simple logging demon implementation
*
* @author Freie Universität Berlin, Computer Systems & Telematics
* @author Thomas Hillebrandt <hillebra@inf.fu-berlin.de>
* @version $Revision: 3854 $
*
* @note $Id: logd.c 3854 2011-12-06 15:27:01Z hwill $
*/
#include
<stdio.h>
#include
<stdlib.h>
#include
<fcntl.h>
#include
<string.h>
/* core */
#include
"msg.h"
#include
"flags.h"
#include
"mutex.h"
#include
"thread.h"
#include
"kernel.h"
/* system */
#include
"logd.h"
#include
"list.h"
typedef
struct
{
list_node_t
listnode
;
char
*
str
;
int
str_len
;
}
log_queue_t
;
static
volatile
int
log_pid
=
-
1
;
static
int
logd_stack_size
=
LOGD_STACK_SIZE_NORMAL
;
static
FILE
*
fh
=
NULL
;
static
int
log_count
=
0
;
static
mutex_t
log_mutex
;
static
list_t
log_msg_queue
;
static
volatile
bool
exit_flag
=
false
;
static
volatile
bool
echo_on
=
false
;
/*---------------------------------------------------------------------------*/
static
void
close_file_handle
(
void
)
{
if
(
fh
!=
NULL
)
{
fclose
(
fh
);
fh
=
NULL
;
}
}
static
void
write_to_file
(
char
*
str
,
int
str_len
)
{
if
(
fh
!=
NULL
&&
str_len
>
0
)
{
if
(
fwrite
(
str
,
sizeof
(
char
),
str_len
,
fh
)
!=
str_len
)
{
if
(
echo_on
&&
logd_stack_size
>=
LOGD_STACK_SIZE_CONSOLE
)
{
printf
(
"LOGD [WARN]: file write failed, closing file
\n
"
);
}
close_file_handle
();
return
;
}
if
(
fflush
(
fh
)
==
EOF
)
{
if
(
echo_on
&&
logd_stack_size
>=
LOGD_STACK_SIZE_CONSOLE
)
{
printf
(
"LOGD [WARN]: file write failed, closing file
\n
"
);
}
close_file_handle
();
return
;
}
}
else
{
fh
=
fopen
(
"/LOGD.LOG"
,
"w"
);
if
(
!
fh
)
{
if
(
echo_on
&&
logd_stack_size
>=
LOGD_STACK_SIZE_CONSOLE
)
{
printf
(
"LOGD [WARN]: file reopen failed, damn!
\n
"
);
}
}
else
{
write_to_file
(
str
,
str_len
);
}
}
}
static
void
logd_process
(
void
)
{
msg
m
;
log_queue_t
*
node
;
do
{
if
(
!
exit_flag
)
{
msg_receive
(
&
m
);
}
mutex_lock
(
&
log_mutex
);
while
((
node
=
(
log_queue_t
*
)
list_remove_head
(
&
log_msg_queue
))
!=
NULL
)
{
write_to_file
(
node
->
str
,
node
->
str_len
);
if
(
echo_on
&&
logd_stack_size
>=
LOGD_STACK_SIZE_CONSOLE
)
{
printf
(
"%s"
,
node
->
str
);
}
log_count
++
;
free
(
node
->
str
);
free
(
node
);
}
mutex_unlock
(
&
log_mutex
);
}
while
(
m
.
type
!=
MSG_EXIT
&&
!
exit_flag
);
/* Logging thread is terminating, close log file */
close_file_handle
();
}
/*---------------------------------------------------------------------------*/
static
void
logd_init0
(
void
)
{
fh
=
fopen
(
"/LOGD.LOG"
,
"w"
);
if
(
!
fh
)
{
return
;
}
log_pid
=
thread_create
(
logd_stack_size
,
PRIORITY_LOGD
,
CREATE_STACKTEST
,
logd_process
,
"logd"
);
}
void
logd_init
(
int
stack_size
)
{
logd_stack_size
=
stack_size
;
mutex_init
(
&
log_mutex
);
list_init
(
&
log_msg_queue
);
logd_init0
();
}
void
logd_set_console_enabled
(
bool
enabled
)
{
echo_on
=
enabled
;
}
bool
logd_log
(
char
*
str
,
int
str_len
)
{
msg
m
;
/* Test if logd process was created */
if
(
log_pid
==
-
1
)
{
/* no logd created, because fopen() on log file failed. So try again */
logd_init0
();
if
(
log_pid
==
-
1
)
{
/* Still errors opening log file, exit now */
return
false
;
}
}
log_queue_t
*
lq
=
malloc
(
sizeof
(
*
lq
));
if
(
lq
==
NULL
)
{
return
false
;
}
lq
->
str
=
malloc
(
sizeof
(
char
)
*
str_len
+
1
);
/* 1 byte for string termination char */
if
(
lq
->
str
==
NULL
)
{
free
(
lq
);
return
false
;
}
strncpy
(
lq
->
str
,
str
,
str_len
);
lq
->
str_len
=
str_len
;
lq
->
str
[
str_len
]
=
'\0'
;
/* add string termination char at end of buffer */
mutex_lock
(
&
log_mutex
);
list_append
(
&
log_msg_queue
,
(
list_node_t
*
)
lq
);
mutex_unlock
(
&
log_mutex
);
m
.
type
=
MSG_POLL
;
m
.
content
.
ptr
=
NULL
;
msg_send
(
&
m
,
log_pid
,
false
);
return
true
;
}
void
logd_exit
(
void
)
{
msg
m
;
/* Test if logd process was created */
if
(
log_pid
==
-
1
)
{
return
;
}
exit_flag
=
true
;
m
.
type
=
MSG_EXIT
;
m
.
content
.
ptr
=
NULL
;
msg_send
(
&
m
,
log_pid
,
false
);
}
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