﻿using System;

namespace VGPrompter {

    public class Logger {

        public bool Enabled { get; set; }
        public string Name { get; private set; }
        Action<object> _logger;

        public Logger(bool enabled = true) : this("Default", enabled: enabled) { }

        public Logger(string name, Action<object> f = null, bool enabled = true) {
            Enabled = enabled;
            Name = name;
            _logger = f ?? Console.WriteLine;
        }

        public void Log(object s) {
            if (Enabled) _logger(s);
        }

    }

}
﻿using System;

namespace VGPrompter {

    [Serializable]
    public class Logger {

        public bool Enabled { get; set; }
        public string Name { get; private set; }
        Action<object> _logger;

        public Logger(bool enabled = true) : this("Default", enabled: enabled) { }

        public Logger(string name, Action<object> f = null, bool enabled = true) {
            Enabled = enabled;
            Name = name;
            _logger = f ?? Console.WriteLine;
        }

        public void Log(object s) {
            if (Enabled) _logger(s);
        }

    }

}
Fix regression in Script serialization
Fix regression in Script serialization

Since the logger in Script is no longer static, the Logger class needs to be serializable.
