Esempio n. 1
0
        public static AssetLogMessage From(Package package, IReference assetReference, ILogMessage logMessage, string assetPath, int line = 0, int character = 0)
        {
            // Transform to AssetLogMessage
            var assetLogMessage = logMessage as AssetLogMessage;

            if (assetLogMessage == null)
            {
                assetLogMessage = new AssetLogMessage(null, assetReference, logMessage.Type, AssetMessageCode.CompilationMessage, assetReference?.Location, logMessage.Text)
                {
                    Exception = (logMessage as LogMessage)?.Exception
                };
            }

            // Set file (and location if available)
            assetLogMessage.File      = assetPath;
            assetLogMessage.Line      = line;
            assetLogMessage.Character = character;

            // Generate location (if it's a Yaml exception)
            var yamlException = (logMessage as LogMessage)?.Exception as YamlException;

            if (yamlException != null)
            {
                assetLogMessage.Line      = yamlException.Start.Line;
                assetLogMessage.Character = yamlException.Start.Column;
            }

            return(assetLogMessage);
        }
Esempio n. 2
0
 public AssetSerializableLogMessage(AssetLogMessage logMessage)
     : base(logMessage)
 {
     if (logMessage.AssetReference != null)
     {
         AssetId  = logMessage.AssetReference.Id;
         AssetUrl = logMessage.AssetReference.Location;
     }
 }
Esempio n. 3
0
        public static void Warning(this ILogger logger, Package package, IReference assetReference, AssetMessageCode code, IEnumerable <IReference> relatedGuids, params object[] arguments)
        {
            var logMessage = new AssetLogMessage(package, assetReference, LogMessageType.Warning, code, arguments);

            if (relatedGuids != null)
            {
                logMessage.Related.AddRange(relatedGuids);
            }
            logger.Log(logMessage);
        }
Esempio n. 4
0
        public static void Error(this ILogger logger, Package package, IReference assetReference, AssetMessageCode code, IEnumerable <IReference> relatedGuids, Exception exception = null)
        {
            var logMessage = new AssetLogMessage(package, assetReference, LogMessageType.Error, code)
            {
                Exception = exception
            };

            if (relatedGuids != null)
            {
                logMessage.Related.AddRange(relatedGuids);
            }
            logger.Log(logMessage);
        }