-
Notifications
You must be signed in to change notification settings - Fork 1
/
logging.gleam
35 lines (31 loc) · 865 Bytes
/
logging.gleam
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
pub type LogLevel {
Emergency
Alert
Critical
Error
Warning
Notice
Info
Debug
}
type DoNotLeak
/// Configure the default Erlang logger handler with a pretty Gleam output
/// format, and sets the logging level to `Info`.
///
/// ## Interaction with Elixir
///
/// Elixir's built-in `logger` application removes Erlang's default logger
/// handler and replaces it with its own code, so if you have an Elixir package
/// in your project then this code will not be able to configure the logger as
/// it could normally.
///
@external(erlang, "logging_ffi", "configure")
pub fn configure() -> Nil
/// Log a message to the Erlang logger at the given log level.
///
pub fn log(level: LogLevel, message: String) -> Nil {
erlang_log(level, message)
Nil
}
@external(erlang, "logger", "log")
fn erlang_log(level: LogLevel, message: String) -> DoNotLeak