Class
class SimpleLogger
public class SimpleLogger <: Logger {
public init()
public init(name: String, level: LogLevel, output: OutputStream)
}
Description: Implements the Logger interface and provides basic log printing and management functions.
This class supports customizing the log name, logging level, and output stream. By default, the log name is "Logger", the print level is INFO
, and the output stream is stdOut
.
Parent Type:
prop level
public mut prop level: LogLevel
Description: Obtains and modifies the logging level.
Type: LogLevel
init()
public init()
Description: Creates a default SimpleLogger instance.
init(String, LogLevel, OutputStream)
public init(name: String, level: LogLevel, output: OutputStream)
Description: Creates a SimpleLogger instance and specifies the log name, logging level, and output stream.
Parameters:
- name: String: log name
- level: LogLevel: log level
- output: OutputStream: output stream
func debug(String)
public func debug(msg: String): Unit
Description: Prints DEBUG
-level logs.
Parameters:
- msg: String: log content
func error(String)
public func error(msg: String): Unit
Description: Prints ERROR
-level logs.
Parameters:
- msg: String: log content
func flush()
public func flush(): Unit
Description: Refreshes the output stream.
func info(String)
public func info(msg: String): Unit
Description: Prints INFO
-level logs.
Parameters:
- msg: String: log content
func log(LogLevel, String)
public func log(level: LogLevel, msg: String): Unit
Description: Prints logs. The log level must be specified.
Parameters:
func setOutput(OutputStream)
public func setOutput(output: OutputStream): Unit
Description: Sets the output stream to which log information is printed.
Parameters:
- output: OutputStream: output stream
func trace(String)
public func trace(msg: String): Unit
Description: Prints TRACE
-level logs.
Parameters:
- msg: String: log content
func warn(String)
public func warn(msg: String): Unit
Description: Prints WARN
-level logs.
Parameters:
- msg: String: log content