z3-z3-4.13.0.src.api.dotnet.Log.cs Maven / Gradle / Ivy
The newest version!
/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
Log.cs
Abstract:
Z3 Managed API: Log
Author:
Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
--*/
using System.Diagnostics;
using System;
namespace Microsoft.Z3
{
///
/// Interaction logging for Z3.
///
///
/// Note that this is a global, static log and if multiple Context
/// objects are created, it logs the interaction with all of them.
///
public static class Log
{
private static bool m_is_open = false;
///
/// Open an interaction log file.
///
/// the name of the file to open
/// True if opening the log file succeeds, false otherwise.
public static bool Open(string filename)
{
m_is_open = true;
return Native.Z3_open_log(filename) == 1;
}
///
/// Closes the interaction log.
///
public static void Close()
{
m_is_open = false;
Native.Z3_close_log();
}
///
/// Appends the user-provided string to the interaction log.
///
public static void Append(string s)
{
Debug.Assert(isOpen());
if (!m_is_open)
throw new Z3Exception("Log cannot be closed.");
Native.Z3_append_log(s);
}
///
/// Checks whether the interaction log is opened.
///
/// True if the interaction log is open, false otherwise.
public static bool isOpen()
{
return m_is_open;
}
}
}