Repository navigation
Expand file tree
/
Copy pathmodule.ae
More file actions
49 lines (42 loc) · 1.51 KB
/
Copy pathmodule.ae
File metadata and controls
49 lines (42 loc) · 1.51 KB
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
// std.log - Logging Module
// Import with: import std.log
//
// err = log.init("app.log", log.LOG_LEVEL_INFO) // "" or "-": stderr
// log.write(log.LOG_LEVEL_WARN, "disk almost full")
//
// A message below the level init (or set_level) gave is dropped.
exports(
log_init_raw, log_shutdown, log_write,
log_set_level, log_set_colors, log_set_timestamps,
log_get_stats, log_print_stats,
init,
LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARN, LOG_LEVEL_ERROR, LOG_LEVEL_FATAL
)
// The levels, lowest first (aether_log.h's LogLevel).
const LOG_LEVEL_DEBUG = 0
const LOG_LEVEL_INFO = 1
const LOG_LEVEL_WARN = 2
const LOG_LEVEL_ERROR = 3
const LOG_LEVEL_FATAL = 4
// Initialize and shutdown. Raw init returns 1/0 for ok/file-open-failed.
extern log_init_raw(filename: string, min_level: int) -> int
extern log_shutdown()
// Write `msg` at `level`, as it is: a % in it is text, not a format.
extern log_write(level: int, msg: string)
// Configuration
extern log_set_level(level: int)
extern log_set_colors(enabled: int)
extern log_set_timestamps(enabled: int)
// Statistics
extern log_get_stats() -> ptr
extern log_print_stats()
// Initialize logging to `filename`, appending, or to stderr when it is ""
// or "-". Returns "" on success, or an error naming a file that could not
// be opened (logging then goes to stderr, so nothing is lost).
init(filename: string, min_level: int) -> {
ok = log_init_raw(filename, min_level)
if ok == 0 {
return "cannot open log file ${filename}"
}
return ""
}