Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions WebViewControl.Avalonia/ConsoleMessageEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;


namespace WebViewControl {
public class ConsoleMessageEventArgs : EventArgs {
public ConsoleMessageEventArgs(ELogSeverity level, string message, string source, int line) {
Level = level;
Message = message;
Source = source;
Line = line;
}

public ELogSeverity Level { get; }

public string Message { get; }

public string Source { get; }

public int Line { get; }

public bool OutputToConsole { get; set; } = true;
}
}
7 changes: 7 additions & 0 deletions WebViewControl.Avalonia/ConsoleMessageEventHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

namespace WebViewControl {

public delegate void ConsoleMessageEventHandler(object sender, ConsoleMessageEventArgs message);

}
46 changes: 46 additions & 0 deletions WebViewControl.Avalonia/ELogSeverity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

namespace WebViewControl {
public enum ELogSeverity {

/// <summary>
/// Default logging (currently INFO logging).
/// </summary>
Default,

/// <summary>
/// Verbose logging.
/// </summary>
Verbose,

/// <summary>
/// DEBUG logging.
/// </summary>
Debug = Verbose,

/// <summary>
/// INFO logging.
/// </summary>
Info,

/// <summary>
/// WARNING logging.
/// </summary>
Warning,

/// <summary>
/// ERROR logging.
/// </summary>
Error,

/// <summary>
/// FATAL logging.
/// </summary>
Fatal,

/// <summary>
/// Disable logging to file for all messages, and to stderr for messages with
/// severity less than FATAL.
/// </summary>
Disable = 99,
}
}
23 changes: 23 additions & 0 deletions WebViewControl/ConsoleMessageEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;


namespace WebViewControl {
public class ConsoleMessageEventArgs : EventArgs {
public ConsoleMessageEventArgs(ELogSeverity level, string message, string source, int line) {
Level = level;
Message = message;
Source = source;
Line = line;
}

public ELogSeverity Level { get; }

public string Message { get; }

public string Source { get; }

public int Line { get; }

public bool OutputToConsole { get; set; } = true;
}
}
7 changes: 7 additions & 0 deletions WebViewControl/ConsoleMessageEventHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System;

namespace WebViewControl {

public delegate void ConsoleMessageEventHandler(object sender, ConsoleMessageEventArgs message);

}
46 changes: 46 additions & 0 deletions WebViewControl/ELogSeverity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

namespace WebViewControl {
public enum ELogSeverity {

/// <summary>
/// Default logging (currently INFO logging).
/// </summary>
Default,

/// <summary>
/// Verbose logging.
/// </summary>
Verbose,

/// <summary>
/// DEBUG logging.
/// </summary>
Debug = Verbose,

/// <summary>
/// INFO logging.
/// </summary>
Info,

/// <summary>
/// WARNING logging.
/// </summary>
Warning,

/// <summary>
/// ERROR logging.
/// </summary>
Error,

/// <summary>
/// FATAL logging.
/// </summary>
Fatal,

/// <summary>
/// Disable logging to file for all messages, and to stderr for messages with
/// severity less than FATAL.
/// </summary>
Disable = 99,
}
}
2 changes: 2 additions & 0 deletions WebViewControl/WebView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public partial class WebView : IDisposable {
public event Action TitleChanged;
public event UnhandledAsyncExceptionEventHandler UnhandledAsyncException;
public event Action</*url*/string> PopupOpening;
public event ConsoleMessageEventHandler ConsoleMessageEmitted;

internal event Action Disposed;
internal event JavascriptContextReleasedEventHandler JavascriptContextReleased;
Expand Down Expand Up @@ -129,6 +130,7 @@ private void Initialize() {
chromium.JavascriptContextReleased += OnJavascriptContextReleased;
chromium.JavascriptUncaughException += OnJavascriptUncaughException;
chromium.UnhandledException += (o, e) => ForwardUnhandledAsyncException(e.Exception);
chromium.ConsoleMessage += (o, e) => ConsoleMessageEmitted.Invoke(o, new ConsoleMessageEventArgs((ELogSeverity)e.Level, e.Message, e.Source, e.Line));

chromium.RequestHandler = new InternalRequestHandler(this);
chromium.LifeSpanHandler = new InternalLifeSpanHandler(this);
Expand Down
Loading