Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
40fdee19
Vérifiée
Valider
40fdee19
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Can specify loglevel in config file
parent
3aaacce0
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
1 requête de fusion
!96
Log levels
Modifications
5
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
5 fichiers modifiés
inc/common/macro.h
+1
-1
1 ajout, 1 suppression
inc/common/macro.h
src/common.c
+1
-1
1 ajout, 1 suppression
src/common.c
src/config.c
+44
-7
44 ajouts, 7 suppressions
src/config.c
src/main/lkt.c
+1
-0
1 ajout, 0 suppression
src/main/lkt.c
src/main/server.c
+4
-4
4 ajouts, 4 suppressions
src/main/server.c
avec
51 ajouts
et
13 suppressions
inc/common/macro.h
+
1
−
1
Voir le fichier @
40fdee19
...
@@ -55,7 +55,7 @@ enum log_level {
...
@@ -55,7 +55,7 @@ enum log_level {
#define LOG(format, level, section, ...) \
#define LOG(format, level, section, ...) \
{ \
{ \
if (level
>
= log_level) \
if (level
<
= log_level) \
fprintf(stderr, " %c %s%s: " format "\n", \
fprintf(stderr, " %c %s%s: " format "\n", \
level == ERROR ? '!' : level == WARN ? '*' : level == INFO ? '.' : ' ', \
level == ERROR ? '!' : level == WARN ? '*' : level == INFO ? '.' : ' ', \
sizeof(section) > sizeof("") ? ("[" section "] ") : "", \
sizeof(section) > sizeof("") ? ("[" section "] ") : "", \
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/common.c
+
1
−
1
Voir le fichier @
40fdee19
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include
<stdarg.h>
#include
<stdarg.h>
#include
<sys/stat.h>
#include
<sys/stat.h>
int
log_level
=
INFO
;
int
log_level
=
0
;
/* None by default */
void
void
__not_implemented
(
const
char
*
func
,
char
*
file
,
int
line
)
__not_implemented
(
const
char
*
func
,
char
*
file
,
int
line
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/config.c
+
44
−
7
Voir le fichier @
40fdee19
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include
<lektor/net.h>
#include
<lektor/net.h>
#include
<lektor/reg.h>
#include
<lektor/reg.h>
#include
<strings.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<errno.h>
#include
<errno.h>
#include
<string.h>
#include
<string.h>
...
@@ -46,6 +47,34 @@ handler(volatile sqlite3 *user, const char *section, const char *name,
...
@@ -46,6 +47,34 @@ handler(volatile sqlite3 *user, const char *section, const char *name,
return
0
;
return
0
;
}
}
static
inline
void
__set_log_level
(
const
char
*
name
,
const
char
*
level
)
{
if
(
!
STR_MATCH
(
name
,
"log"
))
{
LOG_WARN
(
"CONFIG"
,
"Invalid option '%s[:=]%s' with no section"
,
name
,
level
);
return
;
}
if
(
!
level
[
0
])
{
LOG_WARN
(
"CONFIG"
,
"%s"
,
"Invalid empty 'log' option"
);
return
;
}
if
(
STR_MATCH
(
level
,
"error"
))
log_level
=
ERROR
;
else
if
(
STR_MATCH
(
level
,
"warn"
)
||
STR_MATCH
(
level
,
"warning"
))
log_level
=
WARN
;
else
if
(
STR_MATCH
(
level
,
"info"
))
log_level
=
INFO
;
else
if
(
STR_MATCH
(
level
,
"debug"
))
log_level
=
DEBUG
;
else
log_level
=
strtol
(
level
,
NULL
,
0
);
LOG_INFO
(
"CONFIG"
,
"Log level set to %d"
,
log_level
);
}
static
inline
int
static
inline
int
ini_parse
(
const
char
*
path
,
volatile
sqlite3
*
db
)
ini_parse
(
const
char
*
path
,
volatile
sqlite3
*
db
)
{
{
...
@@ -58,6 +87,9 @@ ini_parse(const char *path, volatile sqlite3 *db)
...
@@ -58,6 +87,9 @@ ini_parse(const char *path, volatile sqlite3 *db)
return
1
;
return
1
;
}
}
memset
(
section
,
0
,
INI_MAX_SECTION_LEN
);
memset
(
line
,
0
,
INI_MAX_LINE_LEN
);
/* Parse the file */
/* Parse the file */
while
(
NULL
!=
fgets
(
line
,
INI_MAX_LINE_LEN
,
file
))
{
while
(
NULL
!=
fgets
(
line
,
INI_MAX_LINE_LEN
,
file
))
{
++
linenum
;
++
linenum
;
...
@@ -102,13 +134,18 @@ ini_parse(const char *path, volatile sqlite3 *db)
...
@@ -102,13 +134,18 @@ ini_parse(const char *path, volatile sqlite3 *db)
value
=
skip
(
value
);
value
=
skip
(
value
);
strip
(
value
);
strip
(
value
);
/* Handle the SECTION, NAME[:=]VALUE */
/* Handle the SECTION, NAME[:=]VALUE
if
(
handler
(
db
,
section
,
name
,
value
))
{
The only option that has no SECTION is the log level:
error
=
1
;
log[:=]ERROR|WARN|INFO|DEBUG|\d+ */
LOG_ERROR
(
"PARSER"
,
"Failed to '[handle] %s, "
if
(
section
[
0
])
{
"%s{:,=}%s' at line '%d'"
,
if
(
handler
(
db
,
section
,
name
,
value
))
{
section
,
name
,
value
,
linenum
);
error
=
1
;
}
LOG_ERROR
(
"PARSER"
,
"Failed to '[handle] %s, "
"%s{:,=}%s' at line '%d'"
,
section
,
name
,
value
,
linenum
);
}
}
else
__set_log_level
(
name
,
value
);
}
}
else
{
else
{
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/main/lkt.c
+
1
−
0
Voir le fichier @
40fdee19
...
@@ -941,6 +941,7 @@ parse_args(args_t *args, int argc, const char **argv)
...
@@ -941,6 +941,7 @@ parse_args(args_t *args, int argc, const char **argv)
int
int
main
(
int
argc
,
const
char
**
argv
)
main
(
int
argc
,
const
char
**
argv
)
{
{
log_level
=
ERROR
;
executable_name
=
"lkt"
;
executable_name
=
"lkt"
;
assert
(
NULL
!=
setlocale
(
LC_ALL
,
"en_US.UTF-8"
));
/* BECAUSE! */
assert
(
NULL
!=
setlocale
(
LC_ALL
,
"en_US.UTF-8"
));
/* BECAUSE! */
assert
(
!
signal
(
SIGPIPE
,
sigpipe__
));
assert
(
!
signal
(
SIGPIPE
,
sigpipe__
));
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/main/server.c
+
4
−
4
Voir le fichier @
40fdee19
...
@@ -66,10 +66,6 @@ main(int argc, char *argv[])
...
@@ -66,10 +66,6 @@ main(int argc, char *argv[])
}
}
normal_launch:
normal_launch:
LOG_INFO
(
"GENERAL"
,
"Lektor launched by user %s (shell: %s, home: %s)"
,
pw
->
pw_name
,
pw
->
pw_shell
,
pw
->
pw_dir
);
if
(
env_get
(
LKT_ENV_RESTART
))
LOG_INFO
(
"GENERAL"
,
"%s"
,
"Lektord has been restarted"
);
reg_set
(
server_reg
);
reg_set
(
server_reg
);
mthread_init
();
mthread_init
();
pthread_create
(
&
th
,
NULL
,
mthread_main
,
NULL
);
pthread_create
(
&
th
,
NULL
,
mthread_main
,
NULL
);
...
@@ -136,6 +132,10 @@ normal_launch:
...
@@ -136,6 +132,10 @@ normal_launch:
lkt_queue_send
(
&
srv
.
queue
,
lkt_event_play_pos
,
(
void
*
)
(
size_t
)
strtol
(
env_current
,
NULL
,
0
));
lkt_queue_send
(
&
srv
.
queue
,
lkt_event_play_pos
,
(
void
*
)
(
size_t
)
strtol
(
env_current
,
NULL
,
0
));
}
}
LOG_INFO
(
"GENERAL"
,
"Lektor was %s, user: %s, shell: %s, home: %s"
,
env_get
(
LKT_ENV_RESTART
)
?
"restarted"
:
"started"
,
pw
->
pw_name
,
pw
->
pw_shell
,
pw
->
pw_dir
);
lkt_listen
(
&
srv
);
lkt_listen
(
&
srv
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter