-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.go
executable file
·49 lines (43 loc) · 1.73 KB
/
log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// AUTOGENERATED - DO NOT EDIT
package tdlib
//#cgo linux CFLAGS: -I/usr/local/include
//#cgo darwin CFLAGS: -I/usr/local/include
//#cgo windows CFLAGS: -IC:/src/td -IC:/src/td/build
//#cgo linux LDFLAGS: -L/usr/local/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdmtproto -ltdapi -ltdactor -ltddb -ltdsqlite -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
//#cgo darwin LDFLAGS: -L/usr/local/lib -L/usr/local/opt/openssl/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdmtproto -ltdapi -ltdactor -ltddb -ltdsqlite -ltdnet -ltdutils -lc++ -lssl -lcrypto -ldl -lz -lm
//#cgo windows LDFLAGS: -LC:/src/td/build/Debug -ltdjson
//#include <stdlib.h>
//#include <td/telegram/td_json_client.h>
//#include <td/telegram/td_log.h>
import "C"
import (
"encoding/json"
"unsafe"
)
// SetFilePath Sets the path to the file to where the internal TDLib log will be written.
// By default TDLib writes logs to stderr or an OS specific log.
// Use this method to write the log to a file instead.
func SetFilePath(path string) {
bytes, _ := json.Marshal(UpdateData{
"@type": "setLogStream",
"log_stream": UpdateData{
"@type": "logStreamFile",
"path": path,
"max_file_size": 10485760,
},
})
query := C.CString(string(bytes))
C.td_json_client_execute(nil, query)
C.free(unsafe.Pointer(query))
}
// SetLogVerbosityLevel Sets the verbosity level of the internal logging of TDLib.
// By default the TDLib uses a verbosity level of 5 for logging.
func SetLogVerbosityLevel(level int) {
bytes, _ := json.Marshal(UpdateData{
"@type": "setLogVerbosityLevel",
"new_verbosity_level": level,
})
query := C.CString(string(bytes))
C.td_json_client_execute(nil, query)
C.free(unsafe.Pointer(query))
}