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é GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
f45dfb1e
Vérifiée
Valider
f45dfb1e
rédigé
22 oct. 2021
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
LOG: Apply the 'log/level' (new value) instead of '/log' with the config
parent
91ecd8b7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!170
Ensure that option config values are present in the db
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
src/base/config.c
+38
-15
38 ajouts, 15 suppressions
src/base/config.c
avec
38 ajouts
et
15 suppressions
src/base/config.c
+
38
−
15
Voir le fichier @
f45dfb1e
...
...
@@ -26,24 +26,17 @@ skip(char *s)
return
s
;
}
static
int
PRIVATE_FUNCTION
int
handler
(
lkt_db
*
user
,
const
char
*
section
,
const
char
*
name
,
const
char
*
value
)
{
RETURN_UNLESS
(
section
&&
name
&&
value
,
"I can't complete the database with incomplete lines"
,
1
);
RETURN_UNLESS
(
database_config_set
(
user
,
section
,
name
,
value
),
"Failed to update the database"
,
1
);
RETURN_UNLESS
(
section
&&
name
&&
value
,
"Skip incomplete line"
,
1
);
RETURN_UNLESS
(
database_config_set
(
user
,
section
,
name
,
value
),
"Failed to update config"
,
1
);
return
0
;
}
static
inline
void
__set_log_level
(
const
char
*
name
,
const
char
*
level
)
PRIVATE_FUNCTION
void
__
_
set_log_level
_internal
(
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"
,
"Invalid empty 'log' option"
);
return
;
...
...
@@ -63,7 +56,33 @@ __set_log_level(const char *name, const char *level)
LOG_INFO
(
"CONFIG"
,
"Log level set to %d"
,
lkt_get_log_level
());
}
static
inline
int
PRIVATE_FUNCTION
void
___set_log_level
(
const
char
*
name
,
const
char
*
level
)
{
/* Just check the key name here */
if
(
!
STR_MATCH
(
name
,
"log"
))
{
LOG_WARN
(
"CONFIG"
,
"Invalid option '%s[:=]%s' with no section"
,
name
,
level
);
return
;
}
___set_log_level_internal
(
level
);
}
PRIVATE_FUNCTION
void
___apply_log_level
(
lkt_db
*
db
)
{
char
loglevel
[
LKT_LINE_MAX
];
if
(
!
database_config_get_text_nospace
(
db
,
"log"
,
"level"
,
loglevel
,
LKT_LINE_MAX
))
{
/* 'log/level' is not present, use the '/log' */
LOG_DEBUG
(
"CONFIG"
,
"No entry in config for 'log/level', set it to the '/log' entry"
);
safe_snprintf
(
loglevel
,
LKT_LINE_MAX
,
"%d"
,
lkt_get_log_level
());
database_config_set
(
db
,
"log"
,
"level"
,
loglevel
);
}
else
{
/* 'log/level' is present, use that one */
___set_log_level_internal
(
loglevel
);
}
}
PRIVATE_FUNCTION
int
ini_parse
(
const
char
*
path
,
lkt_db
*
db
)
{
char
*
start
,
*
end
,
*
name
,
*
value
;
...
...
@@ -132,8 +151,10 @@ ini_parse(const char *path, lkt_db *db)
LOG_ERROR
(
"PARSER"
,
"Failed to '[handle] %s, %s{:,=}%s' at line '%d'"
,
section
,
name
,
value
,
linenum
);
}
}
else
__set_log_level
(
name
,
value
);
}
else
{
/* Keep for legacy reasons */
___set_log_level
(
name
,
value
);
}
}
else
{
...
...
@@ -143,6 +164,8 @@ ini_parse(const char *path, lkt_db *db)
}
}
___apply_log_level
(
db
);
/* End of the function */
fclose
(
file
);
if
(
error
)
...
...
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