src/Tools/VSCode/src/logger.scala
author wenzelm
Mon, 19 Dec 2016 20:27:49 +0100
changeset 64605 9c1173a7e4cb
permissions -rw-r--r--
basic support for VSCode Language Server protocol; minimal extension for VSCode editor;

/*  Title:      Tools/VSCode/src/logger.scala
    Author:     Makarius

Minimal logging support.
*/

package isabelle.vscode


import isabelle._


object Logger
{
  def make(log_file: Option[Path]): Logger =
    log_file match { case Some(file) => new File_Logger(file) case None => No_Logger }
}

trait Logger
{
  def apply(msg: => String): Unit
}

object No_Logger extends Logger
{
  def apply(msg: => String) { }
}

class File_Logger(path: Path) extends Logger
{
  def apply(msg: => String) { synchronized { File.append(path, msg + "\n") } }

  override def toString: String = path.toString
}