Example #1
0
        public static void DataLogSDCard(string str)
        {
            try
            {
                // Create an instance of Logger if you need to write to a custom location.
                SDCardLogger customLogger = new SDCardLogger(@"Data", "all.txt", true);
                customLogger.CustomPrefixDateTime = true;
                customLogger.CustomLogToFile = true;
                customLogger.LogCustom(str);

                SDCardLogger.Flush();

                // MUST always call Close to save information
                // you may also call Flush() when you need to save information.
                SDCardLogger.Close();
                customLogger.CloseCustomStreamWriter();
            }
            catch (Exception ex)
            {
                Debug.Print("Error DataLogSDCard  : " + ex.Message);
            }
            finally {
                SDCardLogger.Close();
            }
        }
        public static void LoggerTestSDCard()
        {
            // Directly start logging, no need to create any instance of Logger class
            SDCardLogger.LogToFile = true;    // if false it will only do Debug.Print()
            SDCardLogger.Append = true;       // will append the information to existing if any
            SDCardLogger.PrefixDateTime = true; // add a time stamp on each Log call. Note: Netduino time is not same as clock time.

            // any number of arguments can be passed. They will appended by a white space
            SDCardLogger.Log("All", "these", "will", "be", "combined", "in", "to", "one", "string");
            SDCardLogger.Log("This should go into the second line.");
            Debug.Print(SDCardLogger.LogFilePath);

            // Create an instance of Logger if you need to write to a custom location.
            SDCardLogger customLogger = new SDCardLogger(@"One\OneOne", "one.txt", true);
            customLogger.CustomPrefixDateTime = false;
            customLogger.CustomLogToFile = true;
            customLogger.LogCustom("All", "these", "will", "be", "combined", "in", "to", "one", "string", "-CustomLogger1.");
            Debug.Print(customLogger.CustomFilePath);

            // MUST always call Close to save information
            // you may also call Flush() when you need to save information.
            SDCardLogger.Close();
            customLogger.CloseCustomStreamWriter();
        }