LogStream.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // This code is derived from jcifs smb client library <jcifs at samba dot org>
  2. // Ported by J. Arturo <webmaster at komodosoft dot net>
  3. //
  4. // This library is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU Lesser General Public
  6. // License as published by the Free Software Foundation; either
  7. // version 2.1 of the License, or (at your option) any later version.
  8. //
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. // Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public
  15. // License along with this library; if not, write to the Free Software
  16. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. using System;
  18. using System.Diagnostics;
  19. using System.IO;
  20. using System.Text;
  21. //using Windows.Storage;
  22. //using Windows.UI.Notifications;
  23. using SharpCifs.Util.Sharpen;
  24. namespace SharpCifs.Util
  25. {
  26. /// <summary>
  27. /// 0 - nothing
  28. /// 1 - critical [default]
  29. /// 2 - basic info can be logged under load
  30. /// 3 - almost everything
  31. /// N - debugging
  32. /// </summary>
  33. public class LogStream: PrintWriter
  34. {
  35. private static LogStream _inst = null;
  36. public int Level = 1;
  37. public void SetLevel(int level)
  38. {
  39. this.Level = level;
  40. }
  41. public LogStream(TextWriter other) : base(other)
  42. {
  43. }
  44. /// <summary>
  45. /// This must be called before <tt>getInstance</tt> is called or
  46. /// it will have no effect.
  47. /// </summary>
  48. /// <remarks>
  49. /// This must be called before <tt>getInstance</tt> is called or
  50. /// it will have no effect.
  51. /// </remarks>
  52. public static void SetInstance(TextWriter other)
  53. {
  54. //inst = new Jcifs.Util.LogStream();
  55. _inst = new LogStream(other);
  56. }
  57. public static LogStream GetInstance()
  58. {
  59. if (_inst == null)
  60. {
  61. SetInstance(Console.Error);
  62. }
  63. return _inst;
  64. }
  65. public override Encoding Encoding
  66. {
  67. get { throw new NotImplementedException(); }
  68. }
  69. }
  70. }