mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Some tweaks to the logging system.
This commit is contained in:
parent
eb8430d461
commit
9cce2ee119
2 changed files with 22 additions and 22 deletions
8
snac.c
8
snac.c
|
@ -90,7 +90,7 @@ int validate_uid(const char *uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void srv_debug(int level, xs_str *str)
|
void srv_log(xs_str *str)
|
||||||
/* logs a debug message */
|
/* logs a debug message */
|
||||||
{
|
{
|
||||||
if (xs_str_in(str, srv_basedir) != -1) {
|
if (xs_str_in(str, srv_basedir) != -1) {
|
||||||
|
@ -98,7 +98,6 @@ void srv_debug(int level, xs_str *str)
|
||||||
str = xs_replace_i(str, srv_basedir, "~");
|
str = xs_replace_i(str, srv_basedir, "~");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbglevel >= level) {
|
|
||||||
xs *tm = xs_str_localtime(0, "%H:%M:%S");
|
xs *tm = xs_str_localtime(0, "%H:%M:%S");
|
||||||
fprintf(stderr, "%s %s\n", tm, str);
|
fprintf(stderr, "%s %s\n", tm, str);
|
||||||
|
|
||||||
|
@ -110,13 +109,12 @@ void srv_debug(int level, xs_str *str)
|
||||||
fprintf(f, "%s %s\n", tm, str);
|
fprintf(f, "%s %s\n", tm, str);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
xs_free(str);
|
xs_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void snac_debug(snac *snac, int level, xs_str *str)
|
void snac_log(snac *snac, xs_str *str)
|
||||||
/* prints a user debugging information */
|
/* prints a user debugging information */
|
||||||
{
|
{
|
||||||
xs *o_str = str;
|
xs *o_str = str;
|
||||||
|
@ -127,7 +125,7 @@ void snac_debug(snac *snac, int level, xs_str *str)
|
||||||
msg = xs_replace_i(msg, snac->basedir, "~");
|
msg = xs_replace_i(msg, snac->basedir, "~");
|
||||||
}
|
}
|
||||||
|
|
||||||
srv_debug(level, msg);
|
srv_log(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
18
snac.h
18
snac.h
|
@ -27,11 +27,9 @@ int valid_status(int status);
|
||||||
xs_str *tid(int offset);
|
xs_str *tid(int offset);
|
||||||
double ftime(void);
|
double ftime(void);
|
||||||
|
|
||||||
void srv_debug(int level, xs_str *str);
|
void srv_log(xs_str *str);
|
||||||
#define srv_log(str) srv_debug(0, str)
|
#define srv_debug(level, str) do { if (dbglevel >= (level)) \
|
||||||
|
{ srv_log((str)); } } while (0)
|
||||||
int srv_open(char *basedir, int auto_upgrade);
|
|
||||||
void srv_free(void);
|
|
||||||
|
|
||||||
typedef struct _snac {
|
typedef struct _snac {
|
||||||
xs_str *uid; /* uid */
|
xs_str *uid; /* uid */
|
||||||
|
@ -43,14 +41,18 @@ typedef struct _snac {
|
||||||
xs_str *md5; /* actor url md5 */
|
xs_str *md5; /* actor url md5 */
|
||||||
} snac;
|
} snac;
|
||||||
|
|
||||||
|
void snac_log(snac *user, xs_str *str);
|
||||||
|
#define snac_debug(user, level, str) do { if (dbglevel >= (level)) \
|
||||||
|
{ snac_log((user), (str)); } } while (0)
|
||||||
|
|
||||||
|
int srv_open(char *basedir, int auto_upgrade);
|
||||||
|
void srv_free(void);
|
||||||
|
|
||||||
int user_open(snac *snac, const char *uid);
|
int user_open(snac *snac, const char *uid);
|
||||||
void user_free(snac *snac);
|
void user_free(snac *snac);
|
||||||
xs_list *user_list(void);
|
xs_list *user_list(void);
|
||||||
int user_open_by_md5(snac *snac, const char *md5);
|
int user_open_by_md5(snac *snac, const char *md5);
|
||||||
|
|
||||||
void snac_debug(snac *snac, int level, xs_str *str);
|
|
||||||
#define snac_log(snac, str) snac_debug(snac, 0, str)
|
|
||||||
|
|
||||||
int validate_uid(const char *uid);
|
int validate_uid(const char *uid);
|
||||||
|
|
||||||
xs_str *hash_password(const char *uid, const char *passwd, const char *nonce);
|
xs_str *hash_password(const char *uid, const char *passwd, const char *nonce);
|
||||||
|
|
Loading…
Reference in a new issue