Documentation ¶
Index ¶
- Constants
- func EnableLogging(logLevel, fileLogLevel jww.Threshold, maxLogFileSizeMB int, ...) error
- func EnableThreadLogging(logLevel, fileLogLevel jww.Threshold, maxLogFileSizeMB int, workerName string, ...) error
- func GetLoggerJS(js.Value, []js.Value) any
- type Console
- type JsConsoleLogListener
- type Logger
- type LoggerJS
- func (l *LoggerJS) GetFile(js.Value, []js.Value) any
- func (l *LoggerJS) MaxSize(js.Value, []js.Value) any
- func (l *LoggerJS) Size(js.Value, []js.Value) any
- func (l *LoggerJS) StopLogging(js.Value, []js.Value) any
- func (l *LoggerJS) Threshold(js.Value, []js.Value) any
- func (l *LoggerJS) Worker(js.Value, []js.Value) any
Constants ¶
const ( NewLogFileTag worker.Tag = "NewLogFile" WriteLogTag worker.Tag = "WriteLog" GetFileTag worker.Tag = "GetFile" GetFileExtTag worker.Tag = "GetFileExt" MaxSizeTag worker.Tag = "MaxSize" SizeTag worker.Tag = "Size" )
List of tags that can be used when sending a message or registering a handler to receive a message.
Variables ¶
This section is empty.
Functions ¶
func EnableLogging ¶ added in v0.3.4
func EnableLogging(logLevel, fileLogLevel jww.Threshold, maxLogFileSizeMB int, workerScriptURL, workerName string) error
EnableLogging enables logging to the Javascript console and to a local or worker file buffer. This must be called only once at initialisation.
func EnableThreadLogging ¶ added in v0.3.4
func EnableThreadLogging(logLevel, fileLogLevel jww.Threshold, maxLogFileSizeMB int, workerName string, messagePort js.Value) error
EnableThreadLogging enables logging to the Javascript console and to a local or remote thread file buffer. This must be called only once at initialisation.
Types ¶
type Console ¶
Console contains the Javascript console object, which provides access to the browser's debugging console. This structure is defined for only a single method on the console object. For example, if the method is set to debug, then all calls to console.Write will print a debug message to the Javascript console.
Doc: https://developer.mozilla.org/en-US/docs/Web/API/console
type JsConsoleLogListener ¶
type JsConsoleLogListener struct { jww.Threshold js.Value // contains filtered or unexported fields }
JsConsoleLogListener redirects log output to the Javascript console using the correct console method.
func NewJsConsoleLogListener ¶
func NewJsConsoleLogListener(threshold jww.Threshold) *JsConsoleLogListener
NewJsConsoleLogListener initialises a new log listener that listener for the specific threshold and prints the logs to the Javascript console.
type Logger ¶
type Logger interface { // StopLogging stops log message writes. Once logging is stopped, it cannot // be resumed and the log file cannot be recovered. StopLogging() // GetFile returns the entire log file. GetFile() []byte // Threshold returns the log level threshold used in the file. Threshold() jww.Threshold // MaxSize returns the maximum size, in bytes, of the log file before it // rolls over and starts overwriting the oldest entries MaxSize() int // Size returns the number of bytes written to the log file. Size() int // Worker returns the manager for the Javascript Worker object. If the // worker has not been initialized, it returns nil. Worker() *worker.Manager }
Logger controls and accesses the log file for this binary.
type LoggerJS ¶ added in v0.3.4
type LoggerJS struct {
// contains filtered or unexported fields
}
LoggerJS is the Javascript wrapper for the Logger.
func (*LoggerJS) GetFile ¶ added in v0.3.4
GetFile returns the entire log file.
If the log file is listening locally, it returns it from the local buffer. If it is listening from the worker, it blocks until the file is returned.
Returns a promise:
- Resolves to the log file contents (string).
func (*LoggerJS) MaxSize ¶ added in v0.3.4
MaxSize returns the max size, in bytes, that the log file is allowed to be.
Returns:
- Max file size (int).
func (*LoggerJS) Size ¶ added in v0.3.4
Size returns the current size, in bytes, written to the log file.
If the log file is listening locally, it returns it from the local buffer. If it is listening from the worker, it blocks until the size is returned.
Returns a promise:
- Resolves to the current file size (int).
func (*LoggerJS) StopLogging ¶ added in v0.3.4
StopLogging stops the logging of log messages and disables the log listener. If the log worker is running, it is terminated. Once logging is stopped, it cannot be resumed the log file cannot be recovered.