Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
78f3e7aa
Commit
78f3e7aa
authored
Nov 15, 2013
by
Vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added log level param
parent
bbe52226
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
43 deletions
+88
-43
interface.c
interface.c
+25
-0
main.c
main.c
+11
-2
mtproto-client.c
mtproto-client.c
+52
-41
No files found.
interface.c
View file @
78f3e7aa
...
@@ -50,6 +50,8 @@ int msg_num_mode;
...
@@ -50,6 +50,8 @@ int msg_num_mode;
int
in_readline
;
int
in_readline
;
int
readline_active
;
int
readline_active
;
int
log_level
;
long
long
cur_uploading_bytes
;
long
long
cur_uploading_bytes
;
long
long
cur_uploaded_bytes
;
long
long
cur_uploaded_bytes
;
long
long
cur_downloading_bytes
;
long
long
cur_downloading_bytes
;
...
@@ -278,6 +280,7 @@ char *commands[] = {
...
@@ -278,6 +280,7 @@ char *commands[] = {
"status_offline"
,
"status_offline"
,
"contacts_search"
,
"contacts_search"
,
"quit"
,
"quit"
,
"set"
,
0
};
0
};
int
commands_flags
[]
=
{
int
commands_flags
[]
=
{
...
@@ -315,6 +318,7 @@ int commands_flags[] = {
...
@@ -315,6 +318,7 @@ int commands_flags[] = {
07
,
07
,
07
,
07
,
07
,
07
,
07
,
};
};
int
get_complete_mode
(
void
)
{
int
get_complete_mode
(
void
)
{
...
@@ -769,6 +773,13 @@ void interpreter (char *line UU) {
...
@@ -769,6 +773,13 @@ void interpreter (char *line UU) {
"rename_contact <user> <first-name> <last-name> - tries to rename contact. If you have another device it will be a fight
\n
"
"rename_contact <user> <first-name> <last-name> - tries to rename contact. If you have another device it will be a fight
\n
"
"suggested_contacts - print info about contacts, you have max common friends
\n
"
"suggested_contacts - print info about contacts, you have max common friends
\n
"
"visualize_key <secret_chat> - prints visualization of encryption key. You should compare it to your partner's one
\n
"
"visualize_key <secret_chat> - prints visualization of encryption key. You should compare it to your partner's one
\n
"
"set <param> <param-value>. Possible <param> values are:
\n
"
"
\t
debug_verbosity - just as it sounds. Debug verbosity
\n
"
"
\t
log_level - level of logging of new events. Lower is less verbose:
\n
"
"
\t\t
Level 1: prints info about read messages
\n
"
"
\t\t
Level 2: prints line, when somebody is typing in chat
\n
"
"
\t\t
Level 3: prints line, when somebody changes online status
\n
"
"
\t
msg_num - enables/disables numeration of messages
\n
"
);
);
pop_color
();
pop_color
();
}
else
if
(
IS_WORD
(
"show_license"
))
{
}
else
if
(
IS_WORD
(
"show_license"
))
{
...
@@ -822,6 +833,20 @@ void interpreter (char *line UU) {
...
@@ -822,6 +833,20 @@ void interpreter (char *line UU) {
RET
;
RET
;
}
}
do_contacts_search
(
100
,
s
);
do_contacts_search
(
100
,
s
);
}
else
if
(
IS_WORD
(
"set"
))
{
command
=
next_token
(
&
l
);
long
long
num
=
next_token_int
();
if
(
num
==
NOT_FOUND
)
{
printf
(
"Bad msg id
\n
"
);
RET
;
}
if
(
IS_WORD
(
"debug_verbosity"
))
{
verbosity
=
num
;
}
else
if
(
IS_WORD
(
"log_level"
))
{
log_level
=
num
;
}
else
if
(
IS_WORD
(
"msg_num"
))
{
msg_num_mode
=
num
;
}
}
else
if
(
IS_WORD
(
"quit"
))
{
}
else
if
(
IS_WORD
(
"quit"
))
{
exit
(
0
);
exit
(
0
);
}
}
...
...
main.c
View file @
78f3e7aa
...
@@ -76,6 +76,7 @@ char *downloads_directory;
...
@@ -76,6 +76,7 @@ char *downloads_directory;
char
*
config_directory
;
char
*
config_directory
;
char
*
binlog_file_name
;
char
*
binlog_file_name
;
int
binlog_enabled
;
int
binlog_enabled
;
extern
int
log_level
;
void
set_default_username
(
const
char
*
s
)
{
void
set_default_username
(
const
char
*
s
)
{
if
(
default_username
)
{
if
(
default_username
)
{
...
@@ -260,6 +261,9 @@ void parse_config (void) {
...
@@ -260,6 +261,9 @@ void parse_config (void) {
strcpy
(
buf
+
l
,
"test"
);
strcpy
(
buf
+
l
,
"test"
);
config_lookup_bool
(
&
conf
,
buf
,
&
test_dc
);
config_lookup_bool
(
&
conf
,
buf
,
&
test_dc
);
strcpy
(
buf
+
l
,
"log_level"
);
config_lookup_int
(
&
conf
,
buf
,
&
log_level
);
if
(
!
msg_num_mode
)
{
if
(
!
msg_num_mode
)
{
strcpy
(
buf
+
l
,
"msg_num"
);
strcpy
(
buf
+
l
,
"msg_num"
);
config_lookup_bool
(
&
conf
,
buf
,
&
msg_num_mode
);
config_lookup_bool
(
&
conf
,
buf
,
&
msg_num_mode
);
...
@@ -300,7 +304,7 @@ void inner_main (void) {
...
@@ -300,7 +304,7 @@ void inner_main (void) {
}
}
void
usage
(
void
)
{
void
usage
(
void
)
{
printf
(
"%s [-u username] [-h] [-k public key name] [-N] [-v]
\n
"
,
PROGNAME
);
printf
(
"%s [-u username] [-h] [-k public key name] [-N] [-v]
[-l log_level]
\n
"
,
PROGNAME
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -310,7 +314,7 @@ extern int default_dc_num;
...
@@ -310,7 +314,7 @@ extern int default_dc_num;
void
args_parse
(
int
argc
,
char
**
argv
)
{
void
args_parse
(
int
argc
,
char
**
argv
)
{
int
opt
=
0
;
int
opt
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vn:Nc:p:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vn:Nc:p:
l:
"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'u'
:
case
'u'
:
set_default_username
(
optarg
);
set_default_username
(
optarg
);
...
@@ -331,6 +335,9 @@ void args_parse (int argc, char **argv) {
...
@@ -331,6 +335,9 @@ void args_parse (int argc, char **argv) {
prefix
=
strdup
(
optarg
);
prefix
=
strdup
(
optarg
);
assert
(
strlen
(
prefix
)
<=
100
);
assert
(
strlen
(
prefix
)
<=
100
);
break
;
break
;
case
'l'
:
log_level
=
atoi
(
optarg
);
break
;
case
'h'
:
case
'h'
:
default:
default:
usage
();
usage
();
...
@@ -356,6 +363,8 @@ void sig_handler (int signum) {
...
@@ -356,6 +363,8 @@ void sig_handler (int signum) {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
signal
(
SIGSEGV
,
sig_handler
);
signal
(
SIGSEGV
,
sig_handler
);
signal
(
SIGABRT
,
sig_handler
);
signal
(
SIGABRT
,
sig_handler
);
log_level
=
10
;
args_parse
(
argc
,
argv
);
args_parse
(
argc
,
argv
);
printf
(
printf
(
...
...
mtproto-client.c
View file @
78f3e7aa
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
#include "mtproto-common.h"
#include "mtproto-common.h"
#define MAX_NET_RES (1L << 16)
#define MAX_NET_RES (1L << 16)
extern
int
log_level
;
int
verbosity
;
int
verbosity
;
int
auth_success
;
int
auth_success
;
...
@@ -739,26 +740,30 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -739,26 +740,30 @@ void work_update (struct connection *c UU, long long msg_id UU) {
}
}
}
}
fetch_pts
();
fetch_pts
();
print_start
();
if
(
log_level
>=
1
)
{
push_color
(
COLOR_YELLOW
);
print_start
();
print_date
(
time
(
0
));
push_color
(
COLOR_YELLOW
);
printf
(
" %d messages marked as read
\n
"
,
n
);
print_date
(
time
(
0
));
pop_color
();
printf
(
" %d messages marked as read
\n
"
,
n
);
print_end
();
pop_color
();
print_end
();
}
}
}
break
;
break
;
case
CODE_update_user_typing
:
case
CODE_update_user_typing
:
{
{
peer_id_t
id
=
MK_USER
(
fetch_int
());
peer_id_t
id
=
MK_USER
(
fetch_int
());
peer_t
*
U
=
user_chat_get
(
id
);
peer_t
*
U
=
user_chat_get
(
id
);
print_start
();
if
(
log_level
>=
2
)
{
push_color
(
COLOR_YELLOW
);
print_start
();
print_date
(
time
(
0
));
push_color
(
COLOR_YELLOW
);
printf
(
" User "
);
print_date
(
time
(
0
));
print_user_name
(
id
,
U
);
printf
(
" User "
);
printf
(
" is typing....
\n
"
);
print_user_name
(
id
,
U
);
pop_color
();
printf
(
" is typing....
\n
"
);
print_end
();
pop_color
();
print_end
();
}
}
}
break
;
break
;
case
CODE_update_chat_user_typing
:
case
CODE_update_chat_user_typing
:
...
@@ -767,16 +772,18 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -767,16 +772,18 @@ void work_update (struct connection *c UU, long long msg_id UU) {
peer_id_t
id
=
MK_USER
(
fetch_int
());
peer_id_t
id
=
MK_USER
(
fetch_int
());
peer_t
*
C
=
user_chat_get
(
chat_id
);
peer_t
*
C
=
user_chat_get
(
chat_id
);
peer_t
*
U
=
user_chat_get
(
id
);
peer_t
*
U
=
user_chat_get
(
id
);
print_start
();
if
(
log_level
>=
2
)
{
push_color
(
COLOR_YELLOW
);
print_start
();
print_date
(
time
(
0
));
push_color
(
COLOR_YELLOW
);
printf
(
" User "
);
print_date
(
time
(
0
));
print_user_name
(
id
,
U
);
printf
(
" User "
);
printf
(
" is typing in chat "
);
print_user_name
(
id
,
U
);
print_chat_name
(
chat_id
,
C
);
printf
(
" is typing in chat "
);
printf
(
"....
\n
"
);
print_chat_name
(
chat_id
,
C
);
pop_color
();
printf
(
"....
\n
"
);
print_end
();
pop_color
();
print_end
();
}
}
}
break
;
break
;
case
CODE_update_user_status
:
case
CODE_update_user_status
:
...
@@ -785,15 +792,17 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -785,15 +792,17 @@ void work_update (struct connection *c UU, long long msg_id UU) {
peer_t
*
U
=
user_chat_get
(
user_id
);
peer_t
*
U
=
user_chat_get
(
user_id
);
if
(
U
)
{
if
(
U
)
{
fetch_user_status
(
&
U
->
user
.
status
);
fetch_user_status
(
&
U
->
user
.
status
);
print_start
();
if
(
log_level
>=
3
)
{
push_color
(
COLOR_YELLOW
);
print_start
();
print_date
(
time
(
0
));
push_color
(
COLOR_YELLOW
);
printf
(
" User "
);
print_date
(
time
(
0
));
print_user_name
(
user_id
,
U
);
printf
(
" User "
);
printf
(
" is now "
);
print_user_name
(
user_id
,
U
);
printf
(
"%s
\n
"
,
(
U
->
user
.
status
.
online
>
0
)
?
"online"
:
"offline"
);
printf
(
" is now "
);
pop_color
();
printf
(
"%s
\n
"
,
(
U
->
user
.
status
.
online
>
0
)
?
"online"
:
"offline"
);
print_end
();
pop_color
();
print_end
();
}
}
else
{
}
else
{
struct
user_status
t
;
struct
user_status
t
;
fetch_user_status
(
&
t
);
fetch_user_status
(
&
t
);
...
@@ -1097,14 +1106,16 @@ void work_update (struct connection *c UU, long long msg_id UU) {
...
@@ -1097,14 +1106,16 @@ void work_update (struct connection *c UU, long long msg_id UU) {
M
=
M
->
next
;
M
=
M
->
next
;
}
}
}
}
print_start
();
if
(
log_level
>=
1
)
{
push_color
(
COLOR_YELLOW
);
print_start
();
print_date
(
time
(
0
));
push_color
(
COLOR_YELLOW
);
printf
(
" Encrypted chat "
);
print_date
(
time
(
0
));
print_encr_chat_name_full
(
id
,
user_chat_get
(
id
));
printf
(
" Encrypted chat "
);
printf
(
": %d messages marked read
\n
"
,
x
);
print_encr_chat_name_full
(
id
,
user_chat_get
(
id
));
pop_color
();
printf
(
": %d messages marked read
\n
"
,
x
);
print_end
();
pop_color
();
print_end
();
}
}
}
break
;
break
;
case
CODE_update_chat_participant_add
:
case
CODE_update_chat_participant_add
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment