Beispiel #1
0
        /// <summary>
        /// Parses the day expression.
        /// Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
        /// </summary>
        /// <returns></returns>
        public override Expr Parse()
        {
            LogExpr logexpr = null;

            // CASE 1: logging using OO mode e.g. log.warn ( 'some message' )
            if (_tokenIt.NextToken.Token.Text == "log")
            {
                _tokenIt.Advance();

                // Move past the "." and check the log level in the next if stmt.
                if (_tokenIt.NextToken.Token == Tokens.Dot)
                {
                    _tokenIt.Advance();
                }
            }
            // CASE 2: logging using function mode e.g warn( 'some message' )
            if (LogPluginConstants.ContainsKey(_tokenIt.NextToken.Token.Text))
            {
                logexpr = new LogExpr()
                {
                    Mode = "log", LogLevel = _tokenIt.NextToken.Token.Text
                };
            }
            // CASE 3: Asking for log level
            else if (_tokenIt.NextToken.Token.Text == "level")
            {
                logexpr = new LogExpr()
                {
                    Mode = "level"
                };
            }
            // CASE 4: configuring the logger via parameters.
            else if (_tokenIt.NextToken.Token.Text == "configure")
            {
                logexpr = new LogExpr()
                {
                    Mode = "configure"
                };
            }
            else
            {
                throw _tokenIt.BuildSyntaxUnexpectedTokenException();
            }

            logexpr.Callback = _callback;

            // Move to parameters.
            _tokenIt.Advance();
            bool expectParenthesis = _tokenIt.NextToken.Token == Tokens.LeftParenthesis;

            _parser.ParseParameters(logexpr, expectParenthesis, true, true);
            return(logexpr);
        }
Beispiel #2
0
        /// <summary>
        /// Parses the day expression.
        /// Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
        /// </summary>
        /// <returns></returns>
        public override Expr Parse()
        {
            LogExpr logexpr = null;

            // CASE 1: logging using OO mode e.g. log.warn ( 'some message' )
            if (_tokenIt.NextToken.Token.Text == "log")
            {
                _tokenIt.Advance();

                // Move past the "." and check the log level in the next if stmt.
                if (_tokenIt.NextToken.Token == Tokens.Dot)
                    _tokenIt.Advance();
            }
            // CASE 2: logging using function mode e.g warn( 'some message' )
            if (LogPluginConstants.ContainsKey(_tokenIt.NextToken.Token.Text))
            {
                logexpr = new LogExpr() { Mode = "log", LogLevel = _tokenIt.NextToken.Token.Text };
            }
            // CASE 3: Asking for log level
            else if (_tokenIt.NextToken.Token.Text == "level")
            {
                logexpr = new LogExpr() { Mode = "level" };
            }
            // CASE 4: configuring the logger via parameters.
            else if (_tokenIt.NextToken.Token.Text == "configure")
            {
                logexpr = new LogExpr() { Mode = "configure" };
            }
            else
                throw _tokenIt.BuildSyntaxUnexpectedTokenException();

            logexpr.Callback = _callback;

            // Move to parameters.
            _tokenIt.Advance();
            bool expectParenthesis = _tokenIt.NextToken.Token == Tokens.LeftParenthesis;
            _parser.ParseParameters(logexpr, expectParenthesis, true, true);
            return logexpr;
        }
Beispiel #3
0
 /// <summary>
 /// Shutsdown the log plugin by closing any open file resources.
 /// </summary>
 internal static void Dispose(LogExpr.LogSettings settings)
 {
     try
     {
         if (settings != null && settings.Logger != null)
         {
             settings.Logger.Flush();
             settings.Logger.Dispose();
         }
     }
     catch (Exception)
     {
     }
 }
Beispiel #4
0
        /// <summary>
        /// Shutsdown the log plugin by closing any open file resources.
        /// </summary>
        public void Dispose()
        {
            var settings = _parser.Context.Plugins.GetSettings <LogExpr.LogSettings>("comlib.log");

            LogExpr.Dispose(settings);
        }