2018-02-16 09:24:11 -08:00
|
|
|
|
|
|
|
/*
|
2019-01-15 04:19:08 -08:00
|
|
|
* Eina.Log examples.
|
2018-02-16 09:24:11 -08:00
|
|
|
*
|
|
|
|
* This demo shows how to log at various levels and to change what log is shown.
|
|
|
|
* You can also use a custom log printer in your app as shown in _log_custom.
|
|
|
|
*/
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
2019-03-26 04:19:13 -07:00
|
|
|
public class Example : Efl.Csharp.Application
|
2018-02-16 09:24:11 -08:00
|
|
|
{
|
|
|
|
static double Divide(int num, int denom)
|
|
|
|
{
|
|
|
|
if (denom == 0)
|
2018-11-06 01:39:14 -08:00
|
|
|
Eina.Log.Critical("Attempt to divide by 0\n");
|
2018-02-16 09:24:11 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (denom < 0)
|
2018-11-06 01:39:14 -08:00
|
|
|
Eina.Log.Warning("Possible undesirable effect, divide by negative number");
|
2018-02-16 09:24:11 -08:00
|
|
|
|
|
|
|
double ret = ((double) num / denom);
|
2018-11-06 01:39:14 -08:00
|
|
|
Eina.Log.Info($"{num} / {denom} = {ret}\n");
|
2018-02-16 09:24:11 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Divides()
|
|
|
|
{
|
|
|
|
Divide(5, 1);
|
|
|
|
Divide(5, -1);
|
|
|
|
Divide(5, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void LogLevels()
|
|
|
|
{
|
|
|
|
Console.WriteLine("Executing with default logging");
|
|
|
|
Divides();
|
|
|
|
|
2018-11-06 01:39:14 -08:00
|
|
|
Eina.Log.GlobalLevelSet(Eina.Log.Level.Warning);
|
2019-01-15 04:19:08 -08:00
|
|
|
Console.WriteLine("Executing with Warning level"); // Same as EINA_LOG_LEVEL = 2
|
2018-02-16 09:24:11 -08:00
|
|
|
Divides();
|
|
|
|
|
2018-11-06 01:39:14 -08:00
|
|
|
Eina.Log.GlobalLevelSet(Eina.Log.Level.Info);
|
2019-01-15 04:19:08 -08:00
|
|
|
Console.WriteLine("Executing with Info on"); // Same as EINA_LOG_LEVEL = 3
|
2018-02-16 09:24:11 -08:00
|
|
|
Divides();
|
|
|
|
}
|
|
|
|
|
2019-06-28 15:46:12 -07:00
|
|
|
protected override void OnInitialize(string[] args)
|
2018-02-16 09:24:11 -08:00
|
|
|
{
|
|
|
|
LogLevels();
|
|
|
|
|
|
|
|
// TODO: missing
|
|
|
|
//LogCustom();
|
|
|
|
|
2019-03-26 04:19:13 -07:00
|
|
|
Efl.App.AppMain.Quit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if WIN32
|
|
|
|
[STAThreadAttribute()]
|
|
|
|
#endif
|
|
|
|
public static void Main()
|
|
|
|
{
|
|
|
|
var example = new Example();
|
2019-09-12 06:01:45 -07:00
|
|
|
example.Launch(Efl.Csharp.Components.Basic);
|
2018-02-16 09:24:11 -08:00
|
|
|
}
|
|
|
|
}
|